How to preserve decimal places on export to excel
How to preserve decimal places on export to excel
jezame
Posts: 3Questions: 2Answers: 0
I'm sure this must be an old question but I can't find the answer.
I am using buttons excelHTML5 to export my table.
I use a render function to format a number in a column to a set number of decimal places but when I export to excel I am just seeing significant figures e.g. 1.20 becomes 1.2
How can I set the number of decimals to display for a column in Excel?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Its not easy as you need to modify the Excel file that is created by Buttons - specifically use the
customize
callback of theexcelHtml5
button to modify the generated XML.You need to add a number format here and then an xf tag here which will use that number format. Finally you need to tell the cell to use that style.
Yes it sucks. I'm thinking of spinning the Excel generator out into its own project since this one was only ever intended to create simple spreadsheets. Of course, time is the major issue there!
Allan
Thanks Allan,
I was going down that route but then thought this is getting way to complex for such a simple problem. But if that's the way it's done I'll keep going.
Cheers,
Jeremy