why dollar symbol is aligned to right of the amount when exported.
why dollar symbol is aligned to right of the amount when exported.
P4nk4j Sh4rm4
Posts: 25Questions: 7Answers: 0
Hi Allan,
when I am exporting data from the data table, the dollar symbol aligned to the right of the column followed by the amount. below is the screenshot was taken from the example of your site.
2.png file shows how the code is rendered into the data table and 1.png shows how it is exported into excel.
Can you please suggest me any solution regarding this alignment.
Thanks & Regards,
S Pankaj Sharma
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I don't know why Excel formats numbers that way, but it does. The spreadsheet that is created has those cells as currency numbers, which is why Excel is formatting them as such.
You could make them plain text using the
customize
callback forexcelHtml5
if you wanted, but then they'd be text, not numbers.Allan
Is it not possible with currency numbers instead of making it into plain text?
I have gone through buttons.html5 js file and found the cases as below which when removed dollar sign appears exactly as it is displayed in the data table, but for few cells with the amount, dollar symbol does not export. May I know if it is the right way to remove these below cases
[===code===]
{
match: /^-?\d+.\d%$/,
style: 60,
fmt: function(a) {
return a / 100
}
}, {
match: /^-?\d+.?\d%$/,
style: 56,
fmt: function(a) {
return a / 100
}
}, {
match: /^-?\$[\d,]+.?\d$/,
style: 57
}, {
match: /^-?£[\d,]+.?\d$/,
style: 58
}, {
match: /^-?€[\d,]+.?\d$/,
style: 59
}, {
match: /^-?\d+$/,
style: 65
}, {
match: /^-?\d+.\d{2}$/,
style: 66
}, {
match: /^([\d,]+)$/,
style: 61,
fmt: function(a) {
return -1 * a.replace(/[()]/g, "")
}
}, {
match: /^([\d,]+.\d{2})$/,
style: 62,
fmt: function(a) {
return -1 * a.replace(/[()]/g, "")
}
}, {
match: /^-?[\d,]+$/,
style: 63
},
{
match: /^-?[\d,]+.\d{2}$/,
style: 64
}
[===code===]
Any help would be appreciated.
Thanks in advance.
can you suggest me code how to change it into plain text??
Set the style to be 0 which is plain text. This example shows how you get set the style for a cell.
If you want the currency symbol on the left, you'd need to create a new style in the XML. I don't know the correct format for that since it is Excel's default to put it on the right (e.g. try making a cell currency type, and it will format it the same way as the exported data).
Allan