fix(excel): flush import data to disk and surface write failures - #282
Open
Jeremy6660 wants to merge 1 commit into
Open
fix(excel): flush import data to disk and surface write failures#282Jeremy6660 wants to merge 1 commit into
Jeremy6660 wants to merge 1 commit into
Conversation
Import wrote rows into ExcelHandler's in-memory package but never set the Modified flag on earlier SaveWorksheet enqueues, so Dispose() treated the session as read-only and discarded the imported data. Set Modified in SaveWorksheet and call handler.Save() after Import so data is persisted and write-back failures surface as command errors instead of being swallowed.
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.
Summary
officecli import <xlsx> /SheetN <file.csv>reports success (Imported N rows x M cols into /Sheet1 ...) but writes nothing to the sheet. The xlsx on disk stays empty, so the imported data is silently lost — CSV and TSV both reproduce this.Root cause
ExcelHandler.Importwrites rows/cells intoExcelHandler's in-memory package, but:SaveWorksheetenqueued the part into_dirtyWorksheetswithout setting theModifiedflag.ExcelHandler.Dispose()therefore treated the whole session as read-only and discarded the in-memory copy (reverted to the on-disk bytes) — the_dirtyWorksheetsentries were never flushed.importcommand layer (CommandBuilder.Import) never explicitly saved; it relied onDispose(), which did nothing because of (1), and reported the returned message string as success regardless.The
setpath worked because it goes through the resident/save machinery that does setModified.Fix
ExcelHandler.Helpers.Sheet.cs:SaveWorksheetnow setsModified = true— a dirty worksheet is itself proof the package was modified, regardless of which caller enqueues it. This is the root-cause fix.CommandBuilder.Import.cs: afterhandler.Import(...), callhandler.Save()explicitly so write-back happens before the success message is printed. Any write-back failure now surfaces as a command error instead of being swallowed onDispose().Validation method (per CONTRIBUTING Rule 2)
Before my fix (v1.0.143 baseline):
After my fix:
Also cross-verified with openpyxl (independent of officecli's own readers): the workbook loaded by a third-party library contains the imported rows after the fix, confirming the bytes were really persisted to disk.
Note: I validated by building the patched source with
dotnet buildand running the CLI against the compiledofficecli.dll(macOS arm64, net10.0.302). CI's multi-platformdotnet buildmatrix should confirm the same for the other RIDs.Checklist