fix: Correct data type 'number' constant to 'n' #89
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.
The official xlsx spec defines that the t property of a cell should have
t='n'
if the cell type is number.This fix also makes the exported Excel sheet work with LibreOffice correctly, since that expects 'n' as the type of number cell.
Before, sheets exported with
@microsoft/connected-workbooks
and opened in LibreOffice Calc would not display numbers in number cells at all, those cells would be blank.For Excel sheets, this does not change anything, since Excel understands
t='n'
as the type as well.Actually,
t='1'
is a derivative from the spec, and it seems to be just per chance that Excel understands it.Therefore, I changed dataTypeKind.number from
t='1'
tot='n'
.In the following, I used the code from https://github.com/microsoft/connected-workbooks?tab=readme-ov-file#2-export-a-table-from-raw-data to export data to a sheet and compare their view in LibreOffice vs Excel. I used Excel online, since I am working on a Linux machine.
The first image shows the result of an export using the original code,
dataTypeKind.number = "1"
, in both applications. Excel Online is on the left, LibreOffice Calc is on the right.The second image is the same, but showing the result of an export using modified code of this library from this PR,
dataTypeKind.number = "n"
.As you can see, in the second image, both applications, LibreOffice and Excel, are showing the numbers correctly.
For further reference, compare the
xlsx
specification, Part 1 “Fundamentals And Markup Language Reference”, 5th edition, December 2016, p. 2451: https://ecma-international.org/publications-and-standards/standards/ecma-376/Please do leave feedback on this PR, since I haven't opened a PR in a public library before.