Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

Diluka
Copy link
Contributor

@Diluka Diluka commented Aug 25, 2025

Summary

This PR fixes issue #2961 where Excel files generated by tools
like DataGrip/IDEA fail to load due to missing r attributes on
<row> and <cell> elements.

Problem: When parsing Excel files without r attributes, the
library throws "Invalid row number in model" error because the
parser expects explicit row and cell references.

Solution:

  • Added currentAddress tracking system to RowXform class
  • Automatically generate missing r attributes based on
    sequential position
  • Reset column counter at the start of each row
  • Maintain full backward compatibility with existing files

Changes:

  • lib/xlsx/xform/sheet/row-xform.js: Added address tracking
    logic and automatic r attribute generation
  • spec/integration/issues/issue-2961-missing-r-attribute.spec.j
    s
    : Added comprehensive test case
  • spec/integration/data/test-issue-2961.xlsx: Added test data
    file from DataGrip

Test plan

Test Results:

# Run specific test for this issue
$ npx mocha --require spec/config/setup
spec/integration/issues/issue-2961-missing-r-attribute.spec.js
  github issues
    ✓ issue 2961 - Invalid row number in model when r attribute
missing

  1 passing (17ms)

# Run all integration tests
$ npm run test:integration
  195 passing (2s)
  1 failing  # Pre-existing issue #1328, unrelated to this change

Backward Compatibility Test:

  • All existing integration tests continue to pass (no
    regressions)
  • Files with existing r attributes work unchanged
  • Files missing r attributes now parse correctly

Manual Testing:

  • ✅ DataGrip-generated Excel file now loads successfully
  • ✅ Cells are parsed in correct positions (A1, B1, C1, A2, B2,
    C2)
  • ✅ Cell values and types are preserved correctly

Related to source code (for typings update)

Core Implementation:

Test Coverage:

Closes #2961,#2075

@Copilot Copilot AI review requested due to automatic review settings August 25, 2025 15:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #2961 where Excel files generated by tools like DataGrip/IDEA fail to load due to missing r attributes on <row> and <cell> elements. The library was throwing "Invalid row number in model" errors when parsing these files.

  • Added automatic address tracking and generation for missing r attributes in row and cell elements
  • Implemented backward compatibility while supporting files without explicit row/cell references
  • Added comprehensive test coverage with a real DataGrip-generated Excel file

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 3 comments.

File Description
lib/xlsx/xform/sheet/row-xform.js Added currentAddress tracking system and automatic r attribute generation logic
spec/integration/issues/issue-2961-missing-r-attribute.spec.js Added test case verifying the fix works with files missing r attributes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

[BUG] Invalid row number in model
1 participant