Skip to content

Conversation

@jalateras
Copy link
Contributor

@jalateras jalateras commented Sep 12, 2025

Summary

  • Fixed coordinate mapping issue in xlsx tool where cell references were transposed
  • Updated parse_cell_reference to return (row, column) instead of (column, row)
  • Added comprehensive tests to verify correct behavior

Problem

The xlsx tool was incorrectly transposing row and column coordinates. When requesting cell A2 (row 2, column 1), it would return the value from B1 (row 1, column 2) instead. This was caused by parse_cell_reference returning coordinates in the wrong order compared to what the umya_spreadsheet library expects.

Solution

  • Changed parse_cell_reference to return (row, col) instead of (col, row) to match umya_spreadsheet's coordinate expectation
  • Updated parse_range and get_range functions to handle the corrected coordinate order
  • Added two new tests:
    • test_coordinate_mapping: Verifies the coordinate system mapping
    • test_issue_4550_row_column_transposition: Specifically tests the reported issue

Test Plan

  • All existing tests pass
  • New tests verify correct cell addressing
  • Code passes formatting (cargo fmt)
  • Code passes linting (cargo clippy)
  • Code compiles without warnings (cargo check)

Fixes #4550

Fixed coordinate mapping issue where parse_cell_reference was returning
(column, row) instead of (row, column), causing Excel cell references
to be transposed. For example, A2 was incorrectly returning B1's value.

The fix ensures parse_cell_reference returns (row, column) to match
umya_spreadsheet's expected coordinate order, and updates parse_range
accordingly.

Added comprehensive tests to verify correct cell addressing behavior.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: jalateras <jima@comware.com.au>
Copy link
Collaborator

@michaelneale michaelneale left a comment

Choose a reason for hiding this comment

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

this looks fine to me - one of those "how did it ever work" moments, but I am sure I have heard complaints before.

@alexhancock alexhancock merged commit e7a7675 into block:main Sep 15, 2025
10 checks passed
michaelneale added a commit that referenced this pull request Sep 16, 2025
* main:
  Fix #4550: Correct row/column transposition in xlsx tool (#4622)
  fix: #4634 #4636 do not always encourage absolute paths (#4641)
  fix(1718): make --dir work when launching Goose.app (#4642)
Comment on lines +376 to +378
// Test that A2 (row 2, column 1) returns the correct value
let a2_value = xlsx.get_cell_value(worksheet, 2, 1)?;
assert_eq!(a2_value.value, "Country", "A2 should contain 'Country'");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this test correct? I think the value in cell A2 is 'Government'.
image

@alexhancock alexhancock mentioned this pull request Sep 23, 2025
HikaruEgashira pushed a commit to HikaruEgashira/goose that referenced this pull request Oct 3, 2025
…4622)

Signed-off-by: jalateras <jima@comware.com.au>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: HikaruEgashira <hikaru-egashira@c-fo.com>
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.

Xlsx Tool of Computer controller seems to transpose rows and columns.

5 participants