Skip to content

fix(import): exclude rowHeader and hidden columns from xlsx/array import mapping - #4955

Draft
simonyang08 wants to merge 1 commit into
tabulator-tables:masterfrom
simonyang08:codex/tabulator-4726-xlsx-rowheader-import
Draft

fix(import): exclude rowHeader and hidden columns from xlsx/array import mapping#4955
simonyang08 wants to merge 1 commit into
tabulator-tables:masterfrom
simonyang08:codex/tabulator-4726-xlsx-rowheader-import

Conversation

@simonyang08

Copy link
Copy Markdown

Fixes #4726

Root cause

Import.structureArrayToColumns maps imported cells to columns by raw index from this.table.getColumns(). That array includes:

  • the rowHeader column, pushed at index 0 by ColumnManager.setColumns when rowHeader is configured,
  • hidden (visible: false) columns, which stay in the list.

The Export side strips both (rowHeader has no field, and columnVisCheck drops it along with invisible columns), so an export → import round-trip shifts every value by one slot when rowHeader is configured and silently writes into hidden fields otherwise. This matches the reporter's JSFiddle and the follow-up observation that hidden columns trigger the same misalignment ("the upload is completely column position/index-based").

Fix

Filter the column list in structureArrayToColumns to skip isRowHeader and !visible columns before the index-based mapping, mirroring what the export actually wrote to the file:

columns = allColumns.filter(function(column){
    return column && !column.isRowHeader && column.visible;
});

Two regression tests added to test/unit/modules/Import.spec.js (rowHeader case + hidden-column case). Both were verified to fail on unpatched main and pass with the fix; full unit suite green (498/498).

Known boundaries (not regressions, noted for reviewer awareness)

  • A visible column with no field is excluded by Export (column.field check) but still consumes an import slot; this predates this change and is outside rowHeader breaks table.import("xlsx") #4726's scope.
  • The extreme config rowHeader: {field: "rowid", ...} (rowHeader with a real field) is included by Export by default but skipped by Import after this change. The issue as filed concerns the default fieldless rowHeader, so Import skips isRowHeader unconditionally; happy to adjust if maintainers prefer full symmetry there.

DCO: Signed-off-by: simonyang08 <ppt5928@gmail.com> (commit 5430fe2).

…ort mapping

When importing data via table.import("xlsx") (or any array-of-arrays
importer), Import.structureArrayToColumns was mapping imported cells to
columns by raw index from this.table.getColumns(). That array includes
the rowHeader column at index 0 and any hidden (visible:false) columns
that the Export side strips out, so an export->import round-trip shifted
all values by one slot when rowHeader was configured and silently
dropped/wrote into hidden fields otherwise.

Filter the column list to skip isRowHeader and !visible columns before
index-based mapping so it mirrors what Export.columnVisCheck excludes.

Regression tests added for both the rowHeader and hidden-column cases.

Fixes tabulator-tables#4726

Signed-off-by: simonyang08 <ppt5928@gmail.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.

rowHeader breaks table.import("xlsx")

2 participants