fix(import): exclude rowHeader and hidden columns from xlsx/array import mapping - #4955
Draft
simonyang08 wants to merge 1 commit into
Draft
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4726
Root cause
Import.structureArrayToColumnsmaps imported cells to columns by raw index fromthis.table.getColumns(). That array includes:ColumnManager.setColumnswhenrowHeaderis configured,visible: false) columns, which stay in the list.The Export side strips both (rowHeader has no
field, andcolumnVisCheckdrops it along with invisible columns), so an export → import round-trip shifts every value by one slot whenrowHeaderis 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
structureArrayToColumnsto skipisRowHeaderand!visiblecolumns before the index-based mapping, mirroring what the export actually wrote to the file: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)
column.fieldcheck) but still consumes an import slot; this predates this change and is outside rowHeader breaks table.import("xlsx") #4726's scope.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 skipsisRowHeaderunconditionally; happy to adjust if maintainers prefer full symmetry there.DCO:
Signed-off-by: simonyang08 <ppt5928@gmail.com>(commit 5430fe2).