I am creating a CSV file using JavaScript. I was unable to manage text format(like header text should be bold). Please help me if anyone has any idea around my requirement.
Asked
Active
Viewed 133 times
-1
-
3Please show us what you have tried so far – IMParasharG Mar 18 '19 at 11:44
-
2Show us your code – Thanveer Shah Mar 18 '19 at 11:44
-
3CSV cannot contain any formatting of fonts etc. It is a data only file format. – phuzi Mar 18 '19 at 11:46
-
Possible duplicate of [How to export JavaScript array info to csv (on client side)?](https://stackoverflow.com/questions/14964035/how-to-export-javascript-array-info-to-csv-on-client-side) – Lab Lab Mar 18 '19 at 11:48
-
@Lab Lab, the referenced post does not handle the aspect of "including text format" with CSV, which is not possible. – Marcus Mar 18 '19 at 11:55
1 Answers
0
As far as I know, it is not possible to include text formats in a CSV file. If you want to include formatting information with the data for display in Excel (or am application compatible to some extent with Excel) an alternative may be to produce an XLSX file instead. There are libraries available to do this in Javascript. See, for example, https://github.com/SheetJS/js-xlsx
EDIT: I have just noticed that the freely available community edition of js-xlsx apparently does not support formatting. An alternative is the following library: https://www.npmjs.com/package/exceljs

Marcus
- 1,097
- 11
- 21