Excel merge cells
Excel merge cells
lassenav@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
This discussion has been closed.
Answers
See this discussion for earlier today.
Allan
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
That's jQuery - it selected the
mergeCells
element(s) from therels
variable - which in this case is the generated xml. You could useconsole.log( rels );
to view it in your browser's console.Allan
Thanks
Will take a look
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
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 thecustomize
method to modify the XML that is created.Allan
I'm marking this as answered. You have provided an answer, and then some. I appreciate all the insight and help.
Thanks