Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/officecli/CommandBuilder.Import.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ private static Command BuildImportCommand(Option<bool> jsonOption)
ResidentClient.SendClose(file.FullName);
using var handler = new OfficeCli.Handlers.ExcelHandler(file.FullName, editable: true);
var msg = handler.Import(parentPath, csvContent, delimiter, header, startCell);
// Import works against ExcelHandler's crash-atomic in-memory package.
// Flush before reporting success so write-back failures are surfaced
// as command errors instead of being swallowed by best-effort Dispose.
handler.Save();
if (json)
Console.WriteLine(OutputFormatter.WrapEnvelopeText(msg));
else
Expand Down
6 changes: 6 additions & 0 deletions src/officecli/Handlers/Excel/ExcelHandler.Helpers.Sheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ private static Worksheet GetSheet(WorksheetPart part) =>
/// </summary>
private void SaveWorksheet(WorksheetPart part)
{
// A dirty worksheet is itself proof that the editable package was
// modified. Keep this invariant here instead of relying on every
// caller to set Modified separately: Import writes rows directly and
// used to enqueue the part without setting Modified, so Dispose()
// treated the session as read-only and discarded the in-memory copy.
Modified = true;
_dirtyWorksheets.Add(part);
}

Expand Down