Worksheet Dimensions: fix examples by automatically deducing range #1601

Open
opened 2019-08-15 15:47:34 +00:00 by Vanuan · 1 comment
Vanuan commented 2019-08-15 15:47:34 +00:00 (Migrated from github.com)

There's this !ref property that corresponds to Worksheet Dimensions.

Documentation states:

It specifies the row and column bounds of used cells in the worksheet
When an entire column is formatted, only the first cell in that column is considered used.

Specifically the ref property:

The row and column bounds of all cells in this worksheet. Corresponds to the range that would contain all elements written under . Does not support whole column or whole row reference notation.

The can be various interpretation on whether "used cells" refers to formatting or to cell elements.

Anyway, ref property is unreliable. So I suggest fixing examples to determine range with the following code:

    const cells = Object.keys(sheet).map((key) => dc(key))
    const maxRow = maxBy(cells, 'r').r;
    const maxCol = maxBy(cells, 'c').c;

    range.max = {r: maxRow, c: maxCol};

There's this `!ref` property that corresponds to [Worksheet Dimensions](https://c-rex.net/projects/samples/ooxml/e1/Part4/OOXML_P4_DOCX_dimension_topic_ID0EZ2X4.html). Documentation states: > It specifies the row and column bounds of **used** cells in the worksheet > When an entire column is formatted, only the first cell in that column is considered **used**. Specifically the `ref` property: > The row and column bounds of all cells in this worksheet. Corresponds to the range that would contain all <c> elements written under <sheetData>. **Does not support whole column or whole row reference notation.** The can be various interpretation on whether "used cells" refers to formatting or to cell elements. Anyway, ref property is unreliable. So I suggest fixing examples to determine range with the following code: ``` const cells = Object.keys(sheet).map((key) => dc(key)) const maxRow = maxBy(cells, 'r').r; const maxCol = maxBy(cells, 'c').c; range.max = {r: maxRow, c: maxCol}; ```
SheetJSDev commented 2021-09-11 21:26:10 +00:00 (Migrated from github.com)

The wiki has a sample for updating worksheet range

The "fix" is to change the parsers to recalculate the range, not pushing the code to end users

The wiki has a [sample for updating worksheet range](https://github.com/SheetJS/sheetjs/wiki/General-Utility-Functions#updating-worksheet-range) The "fix" is to change the parsers to recalculate the range, not pushing the code to end users
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#1601
No description provided.