Right Align Dollar Value in Excel Export Footer

Right Align Dollar Value in Excel Export Footer

nportnport Posts: 23Questions: 6Answers: 0
edited February 2022 in Free community support

http://live.datatables.net/dogunepo/2/edit

I'm having an issue where a dollar value that is put in my footer using the footerCallback() is not staying right aligned in the excel export. As you can see in the test case the salary column (and corresponding footer column) is set to be right aligned, and from my understanding the excel export keeps the formatting of the datatable.

I believe the issue is because the value I'm putting in the footer is formatted like this: '$ 10,000' excel is for some reason applying a different format. The reason I put a space between the $ and the number value is because for some reason excel will not format the currencies with the $ to the left of the value which is how I want it to be formatted.

Is there some sort of work around to either right align this value in my footer, or to properly format currency values in excel?

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    This thread should help, it's asking the same thing.

    Cheers,

    Colin

  • nportnport Posts: 23Questions: 6Answers: 0

    @colin so my option is then to essentially host the buttons file and change that instead of using the buttons CDN?

    If possible I was hoping to do this through the customize() function, is there anyway to access the footer through there or no?

    For example I could set the alignment of the pdf footer using
    doc.styles.tableFooter.alignment = 'right'

    Would there be something similar for xlsx or no?

  • nportnport Posts: 23Questions: 6Answers: 0

    @colin I figured out a solution.

    Inside of the customize function( xlsx ) I added the following line of code:
    $('row:last c', sheet).attr('s','57');

    This seemed to solve my issue

  • nportnport Posts: 23Questions: 6Answers: 0

    @colin only issue now is that if the value is negative it will show up like this: $-50.32,
    I just need to find a way to get the negative to the left of the $

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    I modified Kevin's example in that thread to be this - it's using this guide to also set the negative format as well (before it was only setting positive). If you look at "Ashton Cox", that format is now displaying how you wanted.

    Colin

Sign In or Register to comment.