exceljs/exceljs

Boolean cell with value ="true" is returned as 1

nehakseth opened this issue · 2 comments

There is not difference between a boolean cell and a normal text cell.

If i have 2 cells , on with value = "1" and another with value="True" then while reading excel the cell.value function returns 1 for both of them. What is the correct way to read the text "True" from a cell?

This is interesting - I hadn't accounted for boolean values when I first wrote this lib but I can see what is going on...
When you type "True" or "False" into a cell in Excel, it interprets that as a boolean truth value and records the value 1 and 0 in the saved document. It's presented in the UI as "TRUE" and "FALSE" (or some other culturally aware text) but underneath it is 1 and 0.
I will have to add bools - as reading and then writing the spreadsheet will lose the 'bool-ness' though the truthy-ness will be preserved.
For the time-being, when you read a spreadsheet with bools, you can trust the truthyness of the value but for now you will need to translate the text into "true" and "false" yourself.

For the record, I will use the JS values true and false for the cell values (to distinguish from 0 and 1 as numbers) and the .text value will be "true" and "false".

@nehakseth - just published 0.4.0 which includes support for boolean (and error) values.
Bools will now be true or false.