Closed burakgok closed 1 year ago
Sounds like a duplicate of #56. v4.0.0 has some fixes for this and I'll shortly be releasing some updates to create new styles and apply them to individual cells.
I have a table, which is left-aligned, has percentage format and potentially has empty cells. When I do table.write(i, j, "35%")
, left-alignment and percentage format are lost. The resultant cell has no specific alignment, has automatic format and has text value of "35%". When I type 35% in that cell in Numbers, it is interpreted as 0.35 and displayed as a percentage. I am trying to achieve the same thing using numbers-parser. To replicate Numbers' behavior:
write()
or at least there should be a new method or flag.Version v4.1.0 now has support for paragraph styles and cell styles. Numbers stores some styling (background colour and vertical alignment) per-cell rather than in a paragraph style, but number-parser
should keep track of this.
For usage, see new docs for style editing. It's all very new so could still have plenty of bugs. There are some tests for all the new code, but I've not exhaustively tested it yet.
numbers-parser: 4.1.1 Numbers: 13.1 (7037.0.101) Files.zip
bg_color = table.cell("A2").style.bg_color
table.write("A2", "Item 2")
table.cell("A2").style.bg_color = bg_color
I can see most of that visually too, though the percentage format when I open in Numbers 13.1 is still a percentage data format. The alignment is changed to Automatic though.
Curiously automated tests on the data show its changed so there's clearly something else that needs to be updated in the saved file to preserve the formatting. The saved files show the same errors as yours.
I believe this is fixed in 4.1.2. The text inset is not preserved as that's not supported yet, so the new bg_color
style cannot inherit that. Copying styles between cells won't work in the way I think you're hoping; only the supported fields can be copied.
Looking at the defaults of paragraph styles, it looks like an inset of 4pt is the default so I could either set that on new styles or add support. It looks like text padding (what the UI calls a text inset) and the 3 indents configurable in the UI are easily changeable.
Implemented in 4.3
Current behavior of
Table.write
is to overwrite cell content and style altogether. Is there a way to type something in a cell without overwriting its style?Currently, styles of empty cells are lost when saving the document. Can we preserve their styles as well?
In Numbers, when a new row/column is added, depending on the content menu option, the styles of the neighboring row/column are copied. Can we achieve the same effect when an out-of-range cell is referenced in
Table.write
?