Footer losing all formatting when export to Excel

Footer losing all formatting when export to Excel

kevinm2kkevinm2k Posts: 9Questions: 2Answers: 0

Hi,

I have a table with a tfoot, this tfoot consists of values summed up from the table above it, this means it could be a currency/percentage etc.

When using the print button option it is perfect and the formatting is in place.

When using the excel button however everything is formatted except for the tfoot which just reverts to standard text with no currency symbol, no commas, no percentage symbols etc.

Is there a way of getting these back in place?

Kevin

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 3,034Questions: 0Answers: 525
    edited November 29

    Hi @kevinm2k ,

    I just tried it here and it's working as expected for me.

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • kevinm2kkevinm2k Posts: 9Questions: 2Answers: 0

    Very strange, using live.datatables.net and pasting my table in to it... the footer exports to excel fine with formatting, but not on my version. I'm putting all data table js at bottom of page if that makes any difference? I'm also using bootstrap 4. Any ideas why my tfoot is losing formatting??

  • kevinm2kkevinm2k Posts: 9Questions: 2Answers: 0
    edited December 7
  • allanallan Posts: 48,452Questions: 1Answers: 7,015 Site admin
    Answer ✓

    Thanks! Its this line that is causing the issue. Remove that and it would work, but just not bold the text in the footer.

    The issue here is that its difficult to layer styles in Excel. Say you want a bold cell and a bold+number formatted cell. You don't just define a bold style and a number formatting style - you need to define both.

    That is something we absolutely need to address but it is likely a significant amount of work to do it properly. In the short term, remove that line of code.

    Allan

  • kevinm2kkevinm2k Posts: 9Questions: 2Answers: 0

    I guess this means I'll have to host the buttons file myself to make changes. I currently use the CDN. Not a big issue but would rather create an override file if that's at all possible?

  • colincolin Posts: 3,034Questions: 0Answers: 525

    Hi @kevinm2k ,

    I'm not sure about that, especially if the CDN file changes too much in the future. The other option is to remove the bold, as in the example in my first post, that may cause less headaches in the long term,

    Cheers,

    Colin

  • kevinm2kkevinm2k Posts: 9Questions: 2Answers: 0
    edited December 10

    @colin yeah thats my worry about not using the CDN version. Can you show me where I'm adding bold that is causing the issue in the first place? or do you mean its automatic so i need to update my code using the footercallback and remove the styling? If so can you show me an example on my datatables bin?

  • allanallan Posts: 48,452Questions: 1Answers: 7,015 Site admin

    Not footercallback in this case since this is specific to the Excel export file.

    You aren't adding the bold that is causing the issue, that is being done automatically by the line of code I linked to above. As you say though, that would mean you wouldn't be able to use the CDN file. I'd take a pull request that provides a config option to bold the footer cells or not though, that would then be on the cdn in the next Buttons release.

    Longer term, Colin and I are going to figure out a better option for this!

    Allan

  • kevinm2kkevinm2k Posts: 9Questions: 2Answers: 0

    @allan @colin thanks both for your help, datatables has to be one of the best plugins ive come across with jquery so I applaud both of you for the work.

Sign In or Register to comment.