Repository navigation
Spreadsheet 2.0.0: edit cells, formulas, rows and columns; save in place - #70
Merged
Merged
Conversation
… xlsm and ods in place Moves Spreadsheet onto Orca's document session. Edits are an operation log replayed onto the file's own XML, so a save rewrites only edited cells and keeps styles, charts, pictures, comments and macros byte for byte. Formulas recalculate for common functions, references follow inserted and deleted rows and columns, undo and redo are local, and outside writes merge with unsaved edits. .xls and .xlsb open read-only with a notice.
- Merge only disjoint cell edits; set aside anything an outside row or column change could misplace, with reapply or discard. - Operations hold their own cell copies, so a replayed log never shifts a formula twice. - Refuse row and column changes on sheets with linked parts (pivot tables, comments, tables...) or read by pivot caches, charts, table formulas or other sheets' sparklines and rules; refuse pushing cells past the sheet's end. - Save formulas it cannot calculate, array formulas included, without a guessed result; keep dynamic-array metadata; write ; separators as commas. - Refuse edits to Excel table header and totals cells. - Move internal hyperlink targets with their rows.
- Reapply puts back cell edits only, each through the checks a typed edit gets; row and column changes are never reapplied, and they and any refused cell are listed for the person. - Held edits survive later outside writes; the banner says they are unsaved and that closing the tab discards them. - A merge is refused when a formula this tab typed reads cells that changed. - A row insert no longer drops the saved result of formulas it cannot calculate; only deleting data does.
…ange Results such as ROW, MATCH or COUNTBLANK depend on position, so no saved result is kept across a row or column change: formulas the editor calculates are recalculated, the rest are saved without a result for the next app to compute. A merge is also refused when an edited cell became a table header.
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.
ELI5
Spreadsheet 2.0.0 makes spreadsheets editable in Orca (stablyai/orca#20362). You can type values and formulas, insert and delete rows and columns, clear, paste, and undo and redo, then save with Orca's normal save. Saving changes only the cells you edited, so formatting, charts, comments and macros survive.
Safe to merge before the Orca release. The catalog lists 2.0.0 (needs Orca 1.4.248) ahead of 1.1.0 (1.4.245). Orca installs the newest release its version can run, so people on older Orca keep the 1.1.0 viewer.
Before and after, for the user
SUM,IF,COUNTIF,ROUNDand other common functions); anything else keeps its saved result, and Excel recalculates on open.xlsx,.xlsmand.odssave in place through Orca..xlsand.xlsbopen read-only with a notice explaining whyThe mechanism
orca.document.session({ decode, encode, merge }), like Excalidraw 2.1.0. Orca owns the buffer, dirty state, saving, flush-on-close and outside-write conflicts..xlsx/.xlsm: only edited sheets are rewritten, cell by cell, keeping each cell's style. New text is stored inline, so the shared string table is untouched. Every other part (styles, drawings, comments, the macro project) is copied with its exact compressed bytes. The stale calculation chain is dropped, since Excel repairs files that keep one, and the workbook asks Excel to recalculate on open..ods: onlycontent.xmlchanges, and in it only the edited cells. Repeated rows and cells are split as needed.#REF!), in every formula, merge, column width, conditional format, validation rule, hyperlink, page break and defined name. A sheet with something the writer cannot move (drawings, comments, tables, pivot tables, or a chart reading it) refuses the change and says why in the status bar. Its cells stay editable."frame"staysany), so browser clients can edit too. One small MIT zip library is added to the bundle, for synchronous zip reads and writes (the session'sencodeandmergecan't wait). It is listed inTHIRD_PARTY_NOTICES.txt.Why this approach
Re-serializing the whole workbook through a spreadsheet library would be simpler. But a community-edition writer drops styles, charts, comments and conditional formatting, and that loses data silently. Patching the original XML keeps everything we don't understand byte for byte. It also makes
.xlsmsafe to edit, since the macro project is never touched. Where a change can't be applied safely (row shifts under drawings, binary.xls/.xlsb), the editor refuses it and explains why. It never writes a degraded file.Testing
npm testinbuild/: 88 tests. These include writer round-trips against hand-written workbooks with styles, shared strings and formulas, merges, conditional formats, validation, a defined name, a calculation chain, a drawing and a macro project. They check that untouched parts keep their bytes. Session tests run against Orca's real session code throughmockEditorHost(conflict merge, no double replay of accepted edits). Headless browser tests type, use the menu, undo/redo, paste, save and re-read the saved file, in both themes.orca plugin check: ok.orca plugin test: the tests with no npm imports pass. It refuses bare imports, so the writer tests run throughnpm test(gap below).orca plugin shot --editor --act --in-place: typed values and a formula, inserted a row from the menu, then pressed Cmd+S. The file on disk had the edits, the shifted formulas (SUM(B2:B6),Budget!B7on another sheet), its styles and drawing, and no calculation chain. Shots in light and dark are below.node scripts/release-entry.mjsandnode scripts/check-catalog.mjs: ok.Risk
Medium: this writes users' spreadsheets. The writer only rewrites edited sheets or
content.xml, and refuses what it can't move. Known costs: saving after an edit to a 50,000-row sheet takes about 1.5 s, because that sheet's XML is rewritten. Sheets can't be added or renamed yet. Back out by reverting to 1.1.0.