Skip to content

Bug fixes for excel action#4402

Merged
ravirk91 merged 9 commits into
Releases/Official-Releasefrom
BugFix/ExcelAction
Dec 24, 2025
Merged

Bug fixes for excel action#4402
ravirk91 merged 9 commits into
Releases/Official-Releasefrom
BugFix/ExcelAction

Conversation

@AmanPrasad43

@AmanPrasad43 AmanPrasad43 commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

Description

Type of Change

  • Bug fix - [ ] New feature - [ ] Breaking change - [ ] Plugin update

Checklist

  • PR description clearly describes the changes
  • Target branch is correct (master for features, Releases/* for fixes)
  • Latest code from target branch merged
  • No commented/junk code included
  • No new build warnings or errors
  • All existing unit tests pass
  • New unit tests added for new functionality
  • Cross-platform compatibility verified (Windows/Linux/macOS)
  • CI/CD pipeline passes
  • Code follows project conventions (Act{Platform}{Type}, {Platform}Driver)
  • Repository objects use [IsSerializedForLocalRepository] where needed
  • Error handling uses Reporter.ToLog() pattern
  • Documentation updated for user-facing changes
  • Self-review completed and code review comments addressed

Summary by CodeRabbit

  • New Features

    • Support for writing values to Excel cell ranges (e.g., A5:A11).
  • Bug Fixes

    • Fixed field-reset behavior when switching between By-Address and By-Parameters selection modes.
    • Improved resource cleanup during Excel operations.
  • Improvements

    • Dynamic required-field validation based on selection method.
    • Refined UI visibility and control flow for Read/Write modes.
    • Consistent inclusion of cell addresses in returned results and adjusted row indexing.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 24, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

UI, action logic, and NPOI Excel operations updated: UI visibility/validation now driven by ByCellAddress vs ByParameters; ActExcel read/write routing and row-index calculations adjusted; WriteCellData now supports range addresses and workbook cleanup moved to finally.

Changes

Cohort / File(s) Summary
UI Visibility & Validation
Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
Show "Pull Cell Address" only for ReadData when ByParameters is selected; add WriteData branch for non-ByAddress to reveal ColMappingRulesSection and SetDataUsedSection; dynamic required-field validation based on selection mode; reset fields on DataSelection_Changed; remove obsolete commented visibility code.
Action Routing & ReadData adjustments
Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
Replace if/else with switch on ExcelActionType; always include cell address when returning values; change currentRowNum calculation for ByCellAddress to use direct start index; remove dynamic headerRow logic for ByParameters; add explicit error log for unknown action types.
Range Write + Resource Cleanup
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
Support range addresses (e.g., A5:A11) by iterating and writing to each cell; preserve single-cell write path; move workbook close into a finally block for guaranteed cleanup; minor log/message adjustments and clarifying comments.

Sequence Diagram(s)

sequenceDiagram
    participant UI as ActExcelEditPage (UI)
    participant Core as ActExcel (Action Logic)
    participant NPOI as ExcelNPOIOperations (NPOI)

    Note over UI,Core: User chooses DataSelection (ByCellAddress / ByParameters) and action type
    UI->>Core: Submit action (type, selection mode, addresses/rows, value)
    alt ReadData / ByParameters
        Core->>NPOI: Read sheet rows (standard path)
        NPOI-->>Core: Rows with values + addresses
        Core-->>UI: Return params populated (value + address)
    else ReadData / ByCellAddress
        Core->>NPOI: Read using direct start index for cell addresses
        NPOI-->>Core: Cell addresses + values
        Core-->>UI: Return params populated
    else WriteData / AddressRange
        Core->>NPOI: Write value to range (iterate cells)
        NPOI-->>Core: Acknowledge writes
        Core-->>UI: Update status
    end
    Note right of NPOI: Workbook closed in finally block to ensure cleanup
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ravirk91
  • Maheshkale447

Poem

🐰 I hopped through cells both near and far,
Tucked addresses in each data jar,
Ranged writes sowed rows in tidy bands,
UI gates opened by gentle hands—
Excel hums beneath my paws and stars. ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is entirely a blank template with no actual implementation details, bug descriptions, or change explanation filled in; only unchecked checkboxes are present. Complete the Description section with specific details about which bugs were fixed, why they occurred, and how the changes resolve them. Check appropriate checkbox items and verify all checklist items align with actual changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Bug fixes for excel action' is vague and generic, lacking specificity about which bugs were fixed or what aspects of excel action are affected. Replace with a more specific title that describes the actual bug fixes, such as 'Fix Excel action cell address handling and data selection logic' or similar.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch BugFix/ExcelAction

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Ginger/GingerCoreNET/ActionsLib/ActExcel.cs (1)

405-427: Fix off-by-N error in PullCellAddress cell address calculation.

When reading Excel data, the currentRowNum is calculated as 1 + currentRow where currentRow is a 0-indexed loop counter. However, the DataTable returned by ReadData() contains only data rows (no header), and the actual Excel row numbers depend on where the header row is located. If the header is on row 1, data starts on row 2; if on row 2, data starts on row 3, etc.

With the current calculation, all cell addresses start from row 1 regardless of the actual data location in Excel, producing incorrect addresses like A1, B1 instead of the correct A2, B2 (or higher depending on header position).

The fix must account for the header row offset:

-                         int currentRowNum = 1 + currentRow;
+                         int headerRow = int.Parse(CalculatedHeaderRowNum);
+                         int currentRowNum = headerRow + 1 + currentRow;
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a02ce13 and 6081296.

📒 Files selected for processing (3)
  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
  • Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
🧰 Additional context used
📓 Path-based instructions (2)
**/{Ginger,GingerCore}/**/{*Page,*Window}.xaml.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Name pages and windows following the pattern: {Feature}Page or {Feature}Window

Files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
**/*.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Reporter.ToLog(eLogLevel.ERROR, message) for logging errors

Files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
  • Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
🧠 Learnings (8)
📚 Learning: 2025-06-16T10:36:01.993Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4228
File: Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs:83-84
Timestamp: 2025-06-16T10:36:01.993Z
Learning: For the `UnLockType` property in `Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs`, the current naming convention with capital 'L' in the middle should be maintained per project preferences.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-07-16T14:42:32.229Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4254
File: Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/POMLearnConfigWizardPage.xaml.cs:70-73
Timestamp: 2025-07-16T14:42:32.229Z
Learning: In Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/POMLearnConfigWizardPage.xaml.cs, prashelke prefers to keep the current `!WorkSpace.Instance.BetaFeatures.ShowPOMForAI` logic for binding and showing AI POM controls, rather than changing it to positive logic.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-07-09T13:44:51.210Z
Learnt from: GokulBothe99
Repo: Ginger-Automation/Ginger PR: 4245
File: Ginger/Ginger/UserControlsLib/UCDataMapping.xaml.cs:658-667
Timestamp: 2025-07-09T13:44:51.210Z
Learning: In UCDataMapping.xaml.cs SetDatabaseValues() method, the line xDBValueExpression.Visibility = Visibility.Visible is intentionally set unconditionally and works correctly with the visibility logic in SetValueControlsView(). This is the expected behavior per user confirmation.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-12-18T05:29:42.896Z
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4385
File: Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs:468-475
Timestamp: 2025-12-18T05:29:42.896Z
Learning: In the Ginger codebase, assume file extensions are lowercase (e.g., .xlsx, .xls). Do not perform case-insensitive extension checks (such as StringComparison.OrdinalIgnoreCase) when using EndsWith() or similar methods to verify file extensions; rely on lowercase comparisons or convert to lowercase first. This ensures consistency and avoids unnecessary case-insensitive comparisons across C# source files.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
  • Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
📚 Learning: 2025-11-28T05:32:43.529Z
Learnt from: CR
Repo: Ginger-Automation/Ginger PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T05:32:43.529Z
Learning: Applies to **/{GingerCore,GingerCoreNET,GingerCoreCommon}/Actions/Act*.cs : Name actions following the pattern: `Act{PlatformType}{ActionType}` (e.g., `ActBrowserElement`, `ActConsoleCommand`)

Applied to files:

  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
📚 Learning: 2025-11-28T05:32:43.529Z
Learnt from: CR
Repo: Ginger-Automation/Ginger PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T05:32:43.529Z
Learning: Applies to **/{GingerCore,GingerCoreNET,GingerCoreCommon}/Actions/Act*.cs : Actions should inherit from `Act` class and implement platform-specific logic

Applied to files:

  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
📚 Learning: 2025-12-18T05:20:03.536Z
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4385
File: Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml:0-0
Timestamp: 2025-12-18T05:20:03.536Z
Learning: In the Ginger codebase, WPF DataTriggers can use string values (e.g., "ReadCellByIndex", "GetSheetDetails") to compare against enum properties (e.g., eExcelActionType) because WPF automatically handles enum-to-string conversion during DataTrigger evaluation. This pattern is confirmed to work correctly and is acceptable in XAML files.

Applied to files:

  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
📚 Learning: 2025-11-28T05:32:43.529Z
Learnt from: CR
Repo: Ginger-Automation/Ginger PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-28T05:32:43.529Z
Learning: Applies to **/{GingerCore,GingerCoreNET,GingerCoreCommon}/Actions/Act*.cs : On action failure, set `act.Error` and `act.Status = eRunStatus.Failed`

Applied to files:

  • Ginger/GingerCoreNET/ActionsLib/ActExcel.cs
🧬 Code graph analysis (3)
Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (3)
Ginger/GingerCoreNET/ActionsLib/ActExcel.cs (3)
  • ActExcel (37-641)
  • ReadData (365-462)
  • WriteData (527-591)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (1)
  • WriteData (282-296)
Ginger/GingerCoreCommon/InterfacesLib/IExcelOperations.cs (1)
  • WriteData (49-49)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (1)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
Ginger/GingerCoreNET/ActionsLib/ActExcel.cs (5)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (6)
  • WriteData (282-296)
  • DataTable (51-73)
  • DataTable (92-108)
  • DataTable (110-127)
  • DataTable (152-155)
  • DataTable (198-280)
Ginger/GingerCoreCommon/InterfacesLib/IExcelOperations.cs (4)
  • WriteData (49-49)
  • DataTable (35-35)
  • DataTable (37-37)
  • DataTable (59-59)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (1)
  • DataTable (319-331)
Ginger/GingerCoreCommon/Actions/Act.cs (2)
  • AddOrUpdateReturnParamActual (1308-1335)
  • AddOrUpdateReturnParamActualWithPath (1359-1387)
🔇 Additional comments (8)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (2)

494-517: Range writing logic looks correct.

The implementation correctly:

  1. Distinguishes range addresses (containing :) from single-cell addresses
  2. Uses CellRangeAddress.ValueOf to parse range notation
  3. Creates rows/cells as needed with null-coalescing operators
  4. Writes the same value to all cells in the range

The single-cell path uses CellReference appropriately.


535-539: Good addition of finally block for resource cleanup.

This ensures the workbook is closed even if an exception occurs during the write phase, preventing resource leaks.

Ginger/GingerCoreNET/ActionsLib/ActExcel.cs (3)

251-268: Good refactor: switch statement improves readability.

The switch statement is cleaner than chained if/else conditions and provides explicit handling for each action type. The default case correctly logs an error for unmatched actions using Reporter.ToLog(eLogLevel.ERROR, ...), which follows the coding guidelines.


389-390: LGTM: ByCellAddress path correctly stores cell addresses.

The change ensures cell addresses are always stored in the return parameter path when using the ByCellAddress data selection method, which aligns with the enhanced range-writing feature.


294-294: LGTM: Simplified GetSheetDetails.

Directly passing CalculatedHeaderRowNum to ReadData is cleaner.

Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (3)

119-126: LGTM: Visibility constraint for PullCellAddress checkbox.

Restricting the "Pull Cell Address" checkbox to only show when ReadData is selected and "By Parameters" mode is active is correct, as this feature is only relevant for parameter-based data reading.


149-158: LGTM: Visibility logic for WriteData sections.

The logic correctly shows:

  • ColMappingRulesSection only for WriteData (By Address mode)
  • Both ColMappingRulesSection and SetDataUsedSection for WriteData (By Parameters mode)
  • Hides both for other action types

342-354: Good: Field cleanup when switching data selection modes.

Clearing related fields (PullCellAddress, SelectRowsWhere, PrimaryKeyColumn for By Address; PullCellAddress, SelectCellAddress for By Parameters) when switching modes prevents stale data from affecting the action execution.

Comment thread Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs Outdated
Comment thread Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6081296 and 7aedadf.

📒 Files selected for processing (2)
  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
  • Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
🧰 Additional context used
📓 Path-based instructions (2)
**/*.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Reporter.ToLog(eLogLevel.ERROR, message) for logging errors

Files:

  • Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
**/{Ginger,GingerCore}/**/{*Page,*Window}.xaml.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Name pages and windows following the pattern: {Feature}Page or {Feature}Window

Files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
🧠 Learnings (9)
📚 Learning: 2025-12-18T05:29:42.896Z
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4385
File: Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs:468-475
Timestamp: 2025-12-18T05:29:42.896Z
Learning: In the Ginger codebase, assume file extensions are lowercase (e.g., .xlsx, .xls). Do not perform case-insensitive extension checks (such as StringComparison.OrdinalIgnoreCase) when using EndsWith() or similar methods to verify file extensions; rely on lowercase comparisons or convert to lowercase first. This ensures consistency and avoids unnecessary case-insensitive comparisons across C# source files.

Applied to files:

  • Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs
  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-07-16T14:42:32.229Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4254
File: Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/POMLearnConfigWizardPage.xaml.cs:70-73
Timestamp: 2025-07-16T14:42:32.229Z
Learning: In Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/POMLearnConfigWizardPage.xaml.cs, prashelke prefers to keep the current `!WorkSpace.Instance.BetaFeatures.ShowPOMForAI` logic for binding and showing AI POM controls, rather than changing it to positive logic.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-06-16T10:36:01.993Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4228
File: Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs:83-84
Timestamp: 2025-06-16T10:36:01.993Z
Learning: For the `UnLockType` property in `Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs`, the current naming convention with capital 'L' in the middle should be maintained per project preferences.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-08-26T07:40:08.345Z
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4285
File: Ginger/Ginger/Actions/ActionEditPages/ActSecurityTestingEditPage.xaml:23-23
Timestamp: 2025-08-26T07:40:08.345Z
Learning: In the Ginger codebase ActSecurityTestingEditPage.xaml file, the large bottom margin of 530 on the "Acceptable Alerts" label (Margin="10,10,0,530") is intentional design choice, not an error.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2024-08-06T14:31:48.012Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 3851
File: Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs:98-103
Timestamp: 2024-08-06T14:31:48.012Z
Learning: The `LoadGridData` method in `AccessibilityRulePage` should ensure that the `actAccessibilityTesting` field is properly initialized before using it to avoid runtime errors.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-04-30T13:21:34.994Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4193
File: Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/AIGeneratedPreviewWizardPage.xaml.cs:131-138
Timestamp: 2025-04-30T13:21:34.994Z
Learning: In AIGeneratedPreviewWizardPage.xaml.cs, the current code checks if the response ends with triple backticks and removes them manually. This method is fragile and should be replaced with a more robust regex-based parser. The user plans to address this in a future update.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2024-07-26T22:04:12.930Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 3429
File: Ginger/Ginger/AutomatePageLib/AddActionMenu/WindowExplorer/Common/WindowExplorerPage.xaml.cs:1139-1142
Timestamp: 2024-07-26T22:04:12.930Z
Learning: The user has updated the code by removing or addressing the commented code as suggested in the review.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2024-07-26T22:04:12.930Z
Learnt from: IamRanjeetSingh
Repo: Ginger-Automation/Ginger PR: 3488
File: Ginger/GingerCoreNET/DataSource/LiteDB.cs:53-60
Timestamp: 2024-07-26T22:04:12.930Z
Learning: User IamRanjeetSingh has reviewed and accepted the side effects of triggering `TryUpgradeDataFile` upon setting `FileFullPath` in `GingerLiteDB` class.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-07-09T13:44:51.210Z
Learnt from: GokulBothe99
Repo: Ginger-Automation/Ginger PR: 4245
File: Ginger/Ginger/UserControlsLib/UCDataMapping.xaml.cs:658-667
Timestamp: 2025-07-09T13:44:51.210Z
Learning: In UCDataMapping.xaml.cs SetDatabaseValues() method, the line xDBValueExpression.Visibility = Visibility.Visible is intentionally set unconditionally and works correctly with the visibility logic in SetValueControlsView(). This is the expected behavior per user confirmation.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
🧬 Code graph analysis (1)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (2)
Ginger/GingerCoreCommon/ReporterLib/Reporter.cs (1)
  • Reporter (28-357)
Ginger/GingerCoreNET/ActionsLib/ActExcel.cs (1)
  • Col (463-482)
🔇 Additional comments (4)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (1)

535-539: Good improvement to resource cleanup.

Moving workbook?.Close() to a finally block ensures the workbook is properly closed even when exceptions occur, preventing potential file handle leaks.

Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (3)

293-298: Mode-aware validation correctly addresses the previous issue.

The validation logic now correctly determines required fields based on DataSelectionMethod, ensuring that only the relevant fields for the active mode are validated. This resolves the confusing nested validation from the previous implementation.


119-126: UI visibility logic correctly differentiates between modes.

The changes appropriately:

  1. Restrict "Pull Cell Address" checkbox to ReadData with By Parameters mode (line 119)
  2. Show both ColMappingRulesSection and SetDataUsedSection for WriteData in By Parameters mode (lines 149-153)

This provides proper UI feedback based on the selected data selection method.

Also applies to: 149-158


341-354: Field clearing on mode switch prevents stale data issues.

Appropriately clearing mode-specific fields when switching between By Address and By Parameters modes ensures that obsolete values don't inadvertently affect action execution.

Comment on lines +494 to +517
// Handle Range vs Single Cell Writing
if (address.Contains(":"))
{
// --- RANGE LOGIC (e.g. "A5:A11") ---
CellRangeAddress range = CellRangeAddress.ValueOf(address);

cell.SetCellValue(value);
for (int r = range.FirstRow; r <= range.LastRow; r++)
{
IRow row = sheet.GetRow(r) ?? sheet.CreateRow(r);
for (int c = range.FirstColumn; c <= range.LastColumn; c++)
{
ICell cell = row.GetCell(c) ?? row.CreateCell(c);
cell.SetCellValue(value); // Writes the same value to all cells in range
}
}
}
else
{
// --- SINGLE CELL LOGIC (e.g. "A5") ---
CellReference cellRef = new CellReference(address);
IRow row = sheet.GetRow(cellRef.Row) ?? sheet.CreateRow(cellRef.Row);
ICell cell = row.GetCell(cellRef.Col) ?? row.CreateCell(cellRef.Col);
cell.SetCellValue(value);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider validating the address format before parsing.

The range and single-cell logic is well-implemented, correctly creating rows/cells as needed. However, unlike ReadCellData (which uses the regex field at line 43 to validate the address format), WriteCellData passes the address directly to CellRangeAddress.ValueOf() or CellReference. If an invalid address is provided (e.g., "invalid", "123"), NPOI will throw an unclear exception.

🔎 Proposed fix to add address validation
+                    // Validate address format
+                    if (!regex.IsMatch(address))
+                    {
+                        Reporter.ToLog(eLogLevel.ERROR, $"Invalid cell address format: {address}");
+                        return false;
+                    }
+
                     // Handle Range vs Single Cell Writing
                     if (address.Contains(":"))
                     {

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (1)

293-298: LGTM! Mode-aware validation correctly implemented.

The validation logic appropriately checks the DataSelectionMethod and validates only the fields required for the active mode (either SelectCellAddress for By Address or SelectRowsWhere for By Parameters). This resolves the previous validation issue.

📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7aedadf and dbb6284.

📒 Files selected for processing (1)
  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
🧰 Additional context used
📓 Path-based instructions (2)
**/{Ginger,GingerCore}/**/{*Page,*Window}.xaml.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Name pages and windows following the pattern: {Feature}Page or {Feature}Window

Files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
**/*.cs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Reporter.ToLog(eLogLevel.ERROR, message) for logging errors

Files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
🧠 Learnings (9)
📚 Learning: 2025-07-16T14:42:32.229Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4254
File: Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/POMLearnConfigWizardPage.xaml.cs:70-73
Timestamp: 2025-07-16T14:42:32.229Z
Learning: In Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/POMLearnConfigWizardPage.xaml.cs, prashelke prefers to keep the current `!WorkSpace.Instance.BetaFeatures.ShowPOMForAI` logic for binding and showing AI POM controls, rather than changing it to positive logic.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-06-16T10:36:01.993Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4228
File: Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs:83-84
Timestamp: 2025-06-16T10:36:01.993Z
Learning: For the `UnLockType` property in `Ginger/Ginger/Actions/ActionEditPages/ActMobileDeviceEditPage.xaml.cs`, the current naming convention with capital 'L' in the middle should be maintained per project preferences.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-08-26T07:40:08.345Z
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4285
File: Ginger/Ginger/Actions/ActionEditPages/ActSecurityTestingEditPage.xaml:23-23
Timestamp: 2025-08-26T07:40:08.345Z
Learning: In the Ginger codebase ActSecurityTestingEditPage.xaml file, the large bottom margin of 530 on the "Acceptable Alerts" label (Margin="10,10,0,530") is intentional design choice, not an error.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2024-08-06T14:31:48.012Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 3851
File: Ginger/Ginger/SolutionWindows/AccessibilityRulePage.xaml.cs:98-103
Timestamp: 2024-08-06T14:31:48.012Z
Learning: The `LoadGridData` method in `AccessibilityRulePage` should ensure that the `actAccessibilityTesting` field is properly initialized before using it to avoid runtime errors.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-04-30T13:21:34.994Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 4193
File: Ginger/Ginger/ApplicationModelsLib/POMModels/POMWizardLib/LearnWizard/AIGeneratedPreviewWizardPage.xaml.cs:131-138
Timestamp: 2025-04-30T13:21:34.994Z
Learning: In AIGeneratedPreviewWizardPage.xaml.cs, the current code checks if the response ends with triple backticks and removes them manually. This method is fragile and should be replaced with a more robust regex-based parser. The user plans to address this in a future update.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2024-07-26T22:04:12.930Z
Learnt from: prashelke
Repo: Ginger-Automation/Ginger PR: 3429
File: Ginger/Ginger/AutomatePageLib/AddActionMenu/WindowExplorer/Common/WindowExplorerPage.xaml.cs:1139-1142
Timestamp: 2024-07-26T22:04:12.930Z
Learning: The user has updated the code by removing or addressing the commented code as suggested in the review.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2024-07-26T22:04:12.930Z
Learnt from: IamRanjeetSingh
Repo: Ginger-Automation/Ginger PR: 3488
File: Ginger/GingerCoreNET/DataSource/LiteDB.cs:53-60
Timestamp: 2024-07-26T22:04:12.930Z
Learning: User IamRanjeetSingh has reviewed and accepted the side effects of triggering `TryUpgradeDataFile` upon setting `FileFullPath` in `GingerLiteDB` class.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-07-09T13:44:51.210Z
Learnt from: GokulBothe99
Repo: Ginger-Automation/Ginger PR: 4245
File: Ginger/Ginger/UserControlsLib/UCDataMapping.xaml.cs:658-667
Timestamp: 2025-07-09T13:44:51.210Z
Learning: In UCDataMapping.xaml.cs SetDatabaseValues() method, the line xDBValueExpression.Visibility = Visibility.Visible is intentionally set unconditionally and works correctly with the visibility logic in SetValueControlsView(). This is the expected behavior per user confirmation.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
📚 Learning: 2025-12-18T05:29:42.896Z
Learnt from: AmanPrasad43
Repo: Ginger-Automation/Ginger PR: 4385
File: Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs:468-475
Timestamp: 2025-12-18T05:29:42.896Z
Learning: In the Ginger codebase, assume file extensions are lowercase (e.g., .xlsx, .xls). Do not perform case-insensitive extension checks (such as StringComparison.OrdinalIgnoreCase) when using EndsWith() or similar methods to verify file extensions; rely on lowercase comparisons or convert to lowercase first. This ensures consistency and avoids unnecessary case-insensitive comparisons across C# source files.

Applied to files:

  • Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs
🧬 Code graph analysis (1)
Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (3)
Ginger/GingerCoreNET/ActionsLib/ActExcel.cs (6)
  • ActExcel (37-641)
  • ReadData (365-462)
  • WriteData (527-591)
  • List (611-635)
  • CheckMandatoryFieldsExists (593-609)
  • ReadCellData (483-525)
Ginger/GingerCoreNET/Run/Excels/ExcelNPOIOperations.cs (2)
  • WriteData (282-296)
  • List (333-351)
Ginger/GingerCoreCommon/InterfacesLib/IExcelOperations.cs (2)
  • WriteData (49-49)
  • List (75-75)
🔇 Additional comments (4)
Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs (4)

119-119: LGTM! Pull Cell Address checkbox visibility correctly restricted.

The condition now appropriately shows the Pull Cell Address checkbox only when in ReadData mode AND By Parameters is selected, which aligns with the updated By Address/By Parameters architecture.


149-153: LGTM! WriteData visibility logic correctly handles By Parameters mode.

The new branch appropriately shows both ColMappingRulesSection and SetDataUsedSection when in WriteData mode with By Parameters selected, providing the correct UI for this mode.


323-323: LGTM! ReadData now correctly treated like ReadCellData for filter application.

The condition now appropriately includes ReadData alongside ReadCellData when applying filters, ensuring consistent data retrieval behavior across both action types.


352-353: LGTM! Field clearing logic correct for By Parameters mode.

The code appropriately clears PullCellAddress checkbox and SelectCellAddress when switching to By Parameters mode, preventing confusion between modes.

Comment on lines +341 to +346

mAct.DataSelectionMethod = ActExcel.eDataSelectionMethod.ByCellAddress;
rdByParams.IsChecked = false;
//xAddressInputPanel.Visibility = Visibility.Visible;
//if (mAct.ExcelActionType is ActExcel.eExcelActionType.WriteData )
//{
// ColMappingRulesSection.Visibility = Visibility.Visible;
// SetDataUsedSection.Visibility = Visibility.Collapsed;

//}
//else
//{
// ColMappingRulesSection.Visibility = Visibility.Collapsed;
// SetDataUsedSection.Visibility = Visibility.Collapsed;

//}
xPullCellAddressCheckBox.IsChecked = false;
mAct.SelectRowsWhere = string.Empty;
mAct.PrimaryKeyColumn = string.Empty;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Minor cleanup: Remove empty comment and redundant radio button setting.

The field-clearing logic when switching to By Address mode is correct and follows good practices. However:

  1. Line 341 contains an empty comment that should be removed.
  2. Line 343 (rdByParams.IsChecked = false) is redundant—radio button groups handle mutual exclusion automatically.
🔎 Proposed cleanup
-              
             mAct.DataSelectionMethod = ActExcel.eDataSelectionMethod.ByCellAddress;
-            rdByParams.IsChecked = false;
             xPullCellAddressCheckBox.IsChecked = false;
             mAct.SelectRowsWhere = string.Empty;
             mAct.PrimaryKeyColumn = string.Empty;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
mAct.DataSelectionMethod = ActExcel.eDataSelectionMethod.ByCellAddress;
rdByParams.IsChecked = false;
//xAddressInputPanel.Visibility = Visibility.Visible;
//if (mAct.ExcelActionType is ActExcel.eExcelActionType.WriteData )
//{
// ColMappingRulesSection.Visibility = Visibility.Visible;
// SetDataUsedSection.Visibility = Visibility.Collapsed;
//}
//else
//{
// ColMappingRulesSection.Visibility = Visibility.Collapsed;
// SetDataUsedSection.Visibility = Visibility.Collapsed;
//}
xPullCellAddressCheckBox.IsChecked = false;
mAct.SelectRowsWhere = string.Empty;
mAct.PrimaryKeyColumn = string.Empty;
mAct.DataSelectionMethod = ActExcel.eDataSelectionMethod.ByCellAddress;
xPullCellAddressCheckBox.IsChecked = false;
mAct.SelectRowsWhere = string.Empty;
mAct.PrimaryKeyColumn = string.Empty;
🤖 Prompt for AI Agents
In Ginger/Ginger/Actions/ActionEditPages/ActExcelEditPage.xaml.cs around lines
341 to 346, remove the stray empty comment on line 341 and delete the redundant
radio-button assignment on line 343 (rdByParams.IsChecked = false) since radio
groups enforce mutual exclusion; keep the remaining field-clearing assignments
(xPullCellAddressCheckBox.IsChecked = false, mAct.SelectRowsWhere =
string.Empty, mAct.PrimaryKeyColumn = string.Empty) intact.

@ravirk91
ravirk91 enabled auto-merge December 24, 2025 09:01
@ravirk91
ravirk91 disabled auto-merge December 24, 2025 09:24
@ravirk91
ravirk91 merged commit 41cbbba into Releases/Official-Release Dec 24, 2025
5 of 6 checks passed
@ravirk91
ravirk91 deleted the BugFix/ExcelAction branch December 24, 2025 09:24
@coderabbitai coderabbitai Bot mentioned this pull request Dec 24, 2025
15 tasks
@coderabbitai coderabbitai Bot mentioned this pull request Jan 23, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants