New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to write merged cells? #416
Comments
if this is what you want |
Set the There are 5 merges in the file. In the file, they are stored as range objects: > require('xlsx').readFile('merge_cells.xlsx').Sheets.Merge['!merges']
[ { s: { c: 0, r: 0 }, e: { c: 1, r: 1 } }, // <-- The cell A1 represents the range A1:B2
{ s: { c: 2, r: 0 }, e: { c: 2, r: 1 } }, // <-- The cell C1 represents the range C1:C2
{ s: { c: 0, r: 2 }, e: { c: 1, r: 2 } }, // <-- The cell A3 represents the range A3:B3
{ s: { c: 3, r: 0 }, e: { c: 3, r: 1 } }, // <-- The cell D1 represents the range D1:D2
{ s: { c: 0, r: 3 }, e: { c: 1, r: 3 } } ] // <-- The cell A4 represents the range A4:B4 Here is an example from scratch: var XLSX = require('xlsx');
XLSX.writeFile({
SheetNames:["Sheet1"],
Sheets: {
Sheet1: {
"!ref": "A1:B2",
A1:{t:'s', v:"A1:A2"},
B1:{t:'n', v:1},
B2:{t:'b', v:true},
"!merges":[
{s:{r:0,c:0},e:{r:1,c:0}} /* A1:A2 */
]
}
}
}, 'test.xlsx'); |
Thanks! |
Browser-based version of the @SheetJSDev example: https://jsfiddle.net/w8t0g8xn/ |
Thank you! |
Hi, exportToExcel(item: any): void {
} getTableData(table: any, item?: any): any[] { getTableHeaders(table: any, item?: any): any[] { getColspan(header: any, item: any): any { when i am trying to export, the merged cells data is not appearing in headers. can anyone help me on this please |
Hi,
I'm tasked to create sheet with data where some cells are merged (have a single single value), see example below, if this is possible - will you kindly refer to the API method/keyword that elaborate on this?
Thanks,
Yoni
Example where column1 has multiple cells merged
Column1, Column2
USA NY
[Merged with row1] San-Fransisco
[Merged with row1] Atlanta
The text was updated successfully, but these errors were encountered: