Excel merge cells

Excel merge cells

lassenav@hotmail.comlassenav@hotmail.com Posts: 16Questions: 5Answers: 0

There is an example at
https://datatables.net/extensions/buttons/examples/html5/excelTextBold

Can someone show how the cells were merged in row 1?
Thanks

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
  • lassenav@hotmail.comlassenav@hotmail.com Posts: 16Questions: 5Answers: 0

    I'm sorry Allen, I don't understand any of this mergeCell.
    I understand $('c[r=A1] t', sheet).text('Custom text'), sort of.
    What I do understand is xml. I have the customize function which starts like

    customize: function (xlsx) {
    var sheet = xlsx.xl.worksheets['sheet1.xml'];
    let rels = xlsx.xl.worksheets['sheet1.xml']

    But I'm unable to find anything that looks like xml in variable sheet.
    Don't understand how this works...var mergeCells = $('mergeCells', rels);
    Totally unfamiliar with syntax $('mergeCells', rels).
    A total newbie when it comes to these export button framework.
    Do you know the actual path to the generated xml?
    I'm sure I can figure it out from there.
    thanks

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin

    $('mergeCells', rels)

    That's jQuery - it selected the mergeCells element(s) from the rels variable - which in this case is the generated xml. You could use console.log( rels ); to view it in your browser's console.

    Allan

  • lassenav@hotmail.comlassenav@hotmail.com Posts: 16Questions: 5Answers: 0

    Thanks
    Will take a look

  • lassenav@hotmail.comlassenav@hotmail.com Posts: 16Questions: 5Answers: 0

    Thanks Allen,
    Always helpful to get a peek under the hood. :) Still trying to figure out the mergeCells function which looks like its created in the action method of the excel button. Wondering does it matter if the document is already created given the xl object, now, lists which rows they belong to...A1 or E6, etc. So if I wanted to add a row, would I have to update all previously created rows? Can I still insert a row in customize, or do I need to override the action method?

    Thx

  • allanallan Posts: 63,471Questions: 1Answers: 10,467 Site admin
    Answer ✓

    So if I wanted to add a row, would I have to update all previously created rows?

    Yes. Its a major pain I know, but the goal of the Excel export button is not a full abstraction layer to the Open Spreadsheet format (that would be a whole project in its own right).

    Don't override the action method - use the customize method to modify the XML that is created.

    Allan

  • lassenav@hotmail.comlassenav@hotmail.com Posts: 16Questions: 5Answers: 0

    I'm marking this as answered. You have provided an answer, and then some. :) I appreciate all the insight and help.
    Thanks

This discussion has been closed.