File export - Excel

File export - Excel

eddie909eddie909 Posts: 31Questions: 6Answers: 0

Hi,
I need to create an excl doc using File export. Can I use 3 different <thead> tags for each area that contains different colspan? Originally I was using multiple tables but I what to combine the data into 1 table.

I would need my excel doc to look like this (see attachment).

This question has an accepted answers - jump to answer

Answers

  • eddie909eddie909 Posts: 31Questions: 6Answers: 0

    Admin can you please remove the above comments .

    Thanks

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    Yup - they've been deleted and the user banned - thanks!

    With regard to your original question: unfortunately, at this time there is no option to export colspan / rowspan cells to Excel. Its something I would like to add in future, but it isn't something that Buttons currently has the ability to do.

    Allan

  • eddie909eddie909 Posts: 31Questions: 6Answers: 0
    edited July 2016

    Hi Allan,

    Ok, thanks for the feedback. I will modify the layout to make it work.

    1) How can I create an empty row when I convert to excel?
    ex.

    Company Name Address
    test name 101 South Ocean Ave
    empty row

    Product ID Title Amount
    1234 test title 49.99

    thanks for all your help,
    - Ed

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    Hi Ed,

    You would probably need to use the customizeData option of the excelHtml5 button type and modify the data that will be used for the export. That would likely involve inserting an array of empty strings (equal in length to the number of columns in the table) where you want the blank row to appear.

    Allan

  • eddie909eddie909 Posts: 31Questions: 6Answers: 0

    Allan,

    I have no clue on how to do that. Is it something like this?

    buttons: [{
    extend: 'excelHtml5',
    customizeData: function ( data ) {
    // I need to add an empty row between row 2 and 3 - with 16 columns

    thanks,
    - Ed

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin

    Yes exactly. You would need to manipulate the data object. Probably splicing in a new array into the body information where required.

    Allan

  • eddie909eddie909 Posts: 31Questions: 6Answers: 0

    Allan,

    thanks for all your help. Can you please send me an example on how to manipulate the data object?

    thanks,
    - Ed

  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    Answer ✓

    Yes, this is something that would be covered by the DataTables support options.

    Having said that, it should be as simple as data.body.splice( 2, 0, [ /* new array */ ] );.

    Regards,
    Allan

  • eddie909eddie909 Posts: 31Questions: 6Answers: 0

    Thanks again for your quick & great help.

    • Ed
This discussion has been closed.