sheetjs icon indicating copy to clipboard operation
sheetjs copied to clipboard

SSF - ability to format with defined width

Open eyal1990 opened this issue 2 years ago • 1 comments

In order to replicate excel-like behavior it's not enough to format a number (for example), the format should also take into account the cell width and the cell font. This way, a number with a large cell might be formatted into "99999999999". If it will havve less space or the font will be larger the formatted value will be "1.000E+11" and then"1E+11" when has even less space.

I would have liked to have the ability to write something like for a cell of size 100px, with the given font: ssf.format("99999999999", "General", 100, "Calibri 13px");

Does SSF has the ability to do it? If not, do you have any suggestions how to do it or do you have a plan to offer this ability?

Thank you.

eyal1990 avatar May 19 '22 15:05 eyal1990

Not currently, but there are definitely plans to support font-aware rendering as well as reflecting the colors.

Back in 2013 (wow time flies!) the goal was to convert from XLSX / XLS to CSV. Excel ignores column widths in the CSV export, instead performing "General" formatting with the full 11 digit logic.

A good test value is 543212345 since it rounds down:

W Text
9 543212345
8 5.43E+08
7 5.4E+08
6 5E+08
5 ####

SheetJSDev avatar May 19 '22 16:05 SheetJSDev