Exceljs: Number Format - Text

Created on 29 Mar 2018  Â·  4Comments  Â·  Source: exceljs/exceljs

Attempting to write sequential line numbers in a cell like this: '0001'. When a user adds a line and enters line number '0002', Excel will re-format to a number: 2

If I change the cell's number format to Text (in excel) entering the value '0002' will persist.

I attempted to assign a number format when defining the column:
sheet.columns = [{header: 'lineNo', width: 8, style: {alignment: {horizontal: 'right'},numFmt:'Text'}},{...}]

Excel will treat this as a custom format and when you enter '0002' in to the cell, it will reformat to 'T1900xt' with the formula bar value = '1/2/1900'

Tried numFmt:'text' as well with no difference in result.

Love this library BTW.

Most helpful comment

Found the answer in this guide.

for text: numFmt: '@'

All 4 comments

448 as well.

Found the answer in this guide.

for text: numFmt: '@'

How to retrieve the Cell Text as Displayed in Excel?
for currency 340 , displayed value is $340.00 but cell.value and cell.text both return 340 only. So how to get the value with number format?

how to convert the string numbers to int numbers

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dm-ibtissam picture dm-ibtissam  Â·  4Comments

dbsxdbsx picture dbsxdbsx  Â·  3Comments

Toub picture Toub  Â·  3Comments

lukelaws picture lukelaws  Â·  3Comments

ljkmchale picture ljkmchale  Â·  4Comments