Skip to content

fix(xlsx): persist CSV and TSV imports - #333

Open
kriptoburak wants to merge 1 commit into
iOfficeAI:mainfrom
kriptoburak:codex/fix-import-persistence
Open

fix(xlsx): persist CSV and TSV imports#333
kriptoburak wants to merge 1 commit into
iOfficeAI:mainfrom
kriptoburak:codex/fix-import-persistence

Conversation

@kriptoburak

Copy link
Copy Markdown

Fixes #316.

Problem

import changes the worksheet and marks it dirty, but it never marks the handler modified. Editable spreadsheet sessions now use an in-memory package for atomic saves. Dispose() therefore follows its byte-preserving read-only path and discards the imported cells. The command reports success while the workbook stays empty.

Fix

Mark a validated, non-empty import as a mutation before writing its first row. Disposal then flushes the dirty worksheet and atomically writes the package back. Empty input and dimension-validation failures remain non-mutating.

Validation

I reproduced the failure with v1.0.144 on macOS arm64. The command reported Imported 2 rows x 3 cols, while view, dump, and xl/worksheets/sheet1.xml contained no cells.

I built this branch with zero warnings:

dotnet build src/officecli/officecli.csproj --configuration Release --no-restore
Build succeeded.
0 Warning(s)
0 Error(s)

Then I tested both documented input paths. The sample matches a real Xquik extraction CSV, including its UTF-8 BOM and export headers.

printf '\357\273\277Tweet ID,Tweet Text,Tweet Created At\n2082577277246972300,"hello, world",2026-08-21T04:00:00Z\n' > xquik.csv

officecli create stdin.xlsx --locale en-US
officecli import stdin.xlsx /Sheet1 --stdin --header < xquik.csv
officecli view stdin.xlsx text

officecli create file.xlsx --locale en-US
officecli import file.xlsx /Sheet1 xquik.csv --header
officecli get file.xlsx /Sheet1/B2

The fixed build persists the expected cells:

[/Sheet1/row[1]] A1=Tweet ID  B1=Tweet Text  C1=Tweet Created At
[/Sheet1/row[2]] A2=2082577277246972300  B2=hello, world  C2=2026-08-21

/Sheet1/B2 (cell) "hello, world" type=String

The saved worksheet XML now contains both rows plus autoFilter ref="A1:C2" and the frozen pane at A2.

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: import command reports success but writes no data to Excel file

1 participant