cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Export Excel with multiple Headers Using Spreadsheet in SAPUI5

former_member494689
Participant
4,749

Hi Experts,

Is it possible to configure the columns to show the following result using spreadsheet in SAPUI5?

If yes, kindly let us know the sample/reference. Thanks.

To export excel, I refered this link. But, it is just one line header and no merge cells.

https://sapui5.hana.ondemand.com/sdk/#/entity/sap.ui.export.Spreadsheet/sample/sap.ui.export.sample....

Best Regards,

Thiri

View Entire Topic
former_member494689
Participant
0 Likes

Hi all,

I can export the above file format (merged cells in exported excel file) using third-party library 'XLSX.js'.

1. Download the library file from the link : https://github.com/SheetJS/sheetjs

2. Add this library file to your project.

3. Declare the library in your controller.

4. Configure the following code in your controller.

var data = [ *set your data here* ]

/* generate worksheet */

var ws = XLSX.utils.aoa_to_sheet(data);

/* merged cells settings */

var mergedCells = { s: {r: 0, c: 1}, e: {r: 0, c: 2}};

if (!ws["!merges"]) ws["!merges"] = [];

ws["!merges"].push(mergedCells);

/* generate workbook */

var wb = XLSX.utils.book_new();

XLSX.utils.book_append_sheet(wb, ws, "sheet1");

XLSX.writeFile(wb, "test.xlsx");

Best Regards,

Thiri