How to force excelhtml5 with buttons to format numbers as text to preserve leading zeroes
How to force excelhtml5 with buttons to format numbers as text to preserve leading zeroes
lordterrin
Posts: 22Questions: 10Answers: 1
I'm using ButtonCommon
to format my data before writing it to Excel:
'buttons' : [
$.extend( true, {}, buttonCommon, {
extend : 'excelHtml5',
and then my buttonCommon var looks like this (I've taken out the other column ===
lines... it IS there for something ):
temp = [];
var buttonCommon = {
exportOptions: {
format: {
body: function ( data, row, column, node ) {
if ( column === 1) {
temp.push(data);
return data
} else {
return data;
}
}
}
}
};
My temp[]
array that gets written clearly shows that when it's going in, it's a text string, but I cannot get Excel to read it as text - it always formats it as general or number and strips the zeroes.
0 : "000147767"
1 : "000147767"
What do?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I'm afraid its a bug in the current release of Buttons. I'll try to look into it at the start of next week and commit the fix. Certainly the fix will be in the next release of Buttons.
Allan
Thanks very much Allan. I'll patiently wait for your response. You are my hero, man!