fix: resolve the remaining confirmed bugs (0.4.0) - #5
Open
4a4c53 wants to merge 12 commits into
Open
Conversation
Open XML SDK and other .NET producers write <x:worksheet xmlns:x="…"> with every element prefixed. The linear scanner looks for bare tag names, so those files silently read as empty sheets. Normalize each part once on load by stripping the prefix from element names only; attributes such as r:id are untouched. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A <row r="abc"> produced "fila NaN" from setCellAt with no hint of the sheet; a <c r="A5"> inside <row r="1"> silently took the row's number; and a shared-string index past the table (or not a number) silently became null. All three are corrupt files and now fail with a message naming the sheet, the row and the reference. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Excel writes a dragged formula once, on the master cell, and marks the dependents with an empty <f t="shared" si="N"/>. Those cells read back with formula() === null. Keep the master per si and derive each dependent by shifting relative references (new src/formula.ts): text literals and quoted sheet names are left alone, absolute parts are kept, whole-column ranges shift, whole-row ranges are left as-is, and a reference pushed off the grid becomes #REF! like Excel. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
A Date before Excel's epoch serialized to a negative serial, which Excel renders as ##### with no error. Fail toBuffer() with a RangeError naming the cell instead, for plain and cached-formula dates alike. Serial 0 (1899-12-30) stays valid. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
addSheet() rejects 'datos' when 'Datos' exists, yet sheet('datos')
returned null. Excel itself treats sheet names case-insensitively, so
make the lookup match the uniqueness rule.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
_maxRow and _maxCol only ever grew, so clearing a far cell left the sheet reporting (and toRows() materializing) a range that was no longer occupied. Recompute the bounds when the deleted cell sat on the current edge. Rows appended with addRow() keep their reservation even when they end up empty, so the next addRow() still lands below them. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Two columns with the same header collapsed into one key and the first column's values were silently lost. Repeated headers now get _2, _3, … appended until unique, skipping names already taken by other columns. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
isSheetNameError() accepted any Error carrying a rule property. Mark the errors created by validateSheetName with a non-enumerable symbol and check for it, and export isSheetNameError, SheetNameError and SheetNameRule from the package entry point. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
_cells, _maxRow and friends are implementation details shared between Sheet and the writer; they no longer leak into dist/*.d.ts. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Mark the resolved items in docs/bugs.md, leave the t="e" error-cell change as a pending design decision, and describe in the README the case-insensitive sheet lookup, shrinking rowCount/colCount, suffixed duplicate headers, pre-1900 date validation, shared-formula reconstruction, namespace-prefixed parts and the new reader checks. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…bugs # Conflicts: # README.md
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.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.
Resumen
Corrige 11 de los 12 errores confirmados en
docs/bugs.md, uno por commit, y sube la versión a 0.4.0 porque varios cambian comportamiento documentado (sheet(),rowCount/colCount, cabeceras duplicadas).Lectura
<x:worksheet><x:row><x:c>(Open XML SDK, herramientas .NET) se leían como hoja vacía sin error.stripElementPrefixes()normaliza cada parte al cargarla; solo toca nombres de elemento, los atributos comor:idse conservan.<f t="shared" si="N"/>devolvíanformula() === null. Nuevosrc/formula.ts: se guarda la maestra porsiy se desplazan las referencias relativas. Literales de texto y nombres de hoja entrecomillados intactos, partes absolutas conservadas, rangos de columna (A:A) desplazados,#REF!si sale de la cuadrícula. Limitación documentada: los rangos de fila completa (1:1) no se desplazan.<row r="abc">producíafila NaN;<c r="A5">dentro de<row r="1">tomaba la fila 1 en silencio; un índice de shared string inexistente devolvíanull. Los tres lanzan ahora errores que nombran la hoja y la referencia.Escritura
#####.toBuffer()lanzaRangeErrorcon la celda, para fechas planas y valores cacheados de fórmula. El serial 0 sigue siendo válido y la lectura de seriales negativos se mantiene tolerante.API
Workbook.sheet(name)busca sin distinguir mayúsculas, coherente con la unicidad deaddSheety con Excel.rowCount/colCountdecrecen al borrar la celda del borde. Las filas reservadas poraddRow()conservan su sitio aunque queden vacías.toObjects()sufija cabeceras repetidas (_2,_3…) en vez de pisarlas, saltando nombres ya ocupados.isSheetNameError()comprueba una marcaSymbolpropia en vez de cualquierErrorconrule. Se exportanisSheetNameError,SheetNameErrorySheetNameRule.Empaquetado
stripInternal: true: el.d.tspublicado ya no expone_cellsni otros miembros internos.No incluido
t="e"como texto. PR test(helpers): extract synthetic xlsx builders for reuse #2 lo documentó como conversión deliberada. Resolverlo exige ampliarCellValue, un cambio de API para consumidores TypeScript. Queda endocs/bugs.mdcomo decisión pendiente para una versión mayor.Verificación
pnpm testpnpm test:coveragepnpm lint,pnpm typecheck,pnpm buildmain