[excelHtml5 export] customize function doesn't works

[excelHtml5 export] customize function doesn't works

FabCFabC Posts: 2Questions: 1Answers: 0

Hi,
My customer would like to customize the style of the Datatables export.
Initially he has setting up the csvHtml5 button. However, today due to his needs (add images as header, update the background color to the header, change the font and the font color), I quickly understood that I need to move to the excelHTML5 button. So I set up the following code:

{
  extend: 'excelHtml5',
  title: '{{title_csv}}',
  customize: function( xlsx ) {
    var sheet = xlsx.xl.worksheets['sheet1.xml'];
    alert(sheet);
    $('row:first c', sheet).attr( 's', '42' );
  },
  exportOptions: {
    columns: ':visible'
  },
  text: '<i class="fa fa-download"></i>{{"common.list.export"|trans}}',
  className: 'btn btn-primary'
}

Everything works fine except the customize part. I really don't understand what I'm doing wrong. Does someone have an idea?

Thanks in advanced.

Answers

  • FabCFabC Posts: 2Questions: 1Answers: 0

    Hi again,
    I found that the site using the version 1.0.3 for Js files...
    The upgrade seem to be really painful due to customization. Does someone have an easier solution?

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    Hi @FabC ,

    The change should be straightforward, as the customisation should be consistent in both approaches.

    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

  • allanallan Posts: 61,723Questions: 1Answers: 10,108 Site admin

    The customization of the Excel export can be quite difficult. Basically it gives you the chance to modify the XML that the Buttons script creates for Excel. So to modify it you need to know some of the XML structure Excel uses - e.g. for images you need to be able to insert them into the zip file and then reference them.

    It is possible, but its not easy and its not something I've got an example of I'm afraid.

    If you need extensive Excel export customisation I would suggest you use SheetJS rather than our Buttons export. You can still use Buttons as the export trigger, but use SheetJS to define and create your export file.

    Allan

  • jmleitaojmleitao Posts: 6Questions: 2Answers: 0

    Please @allan, it's possible to show an example of how to configure a custom button and use sheetjs?

    Thanks in advance.

  • colincolin Posts: 15,144Questions: 1Answers: 2,586

    That's not something we would do, I'm afraid. It would be worth searching the web in case there are other examples out there,

    Colin

This discussion has been closed.