Utilizing the js-xlsx
library, I am in the process of generating an excel file. However, I have encountered an issue where the order of the columns in my sheet is not as desired after using .json_to_sheet
. For example, the current order looks like this:
100 | 200 | 300| 400| a | b | c
My expected order should be:
a | b | c | 100 | 200 | 300| 400
The headers a | b | c
remain constant, while the numeric column headers may vary.
Is there a way to rearrange the columns in the desired order?
NOTE:
If numerical values are used as headers, xlsx
organizes the columns with numeric headers first before any other type of header. If non-numeric headers are used, the columns can be ordered directly in the JSON data saved.
One workaround is to preface the numbers with a space ' '
, which resolves the ordering issue. However, I would prefer not to add a space before the numbers.