I need to generate an excel in the below format where some headers column are single row and some are multi row and multi column. Also need to add CSS to headings like background color and borders.

i couldn't find any proper solution. All solutions I got were for converting array to excel file.

click here to view the format needed.

1 Answers

0
Nihal Saxena On

use SheetJS library

const headerTitle = 'your header title here';
const sheet = XLSX.utils.json_to_sheet([{}], {
  header: [headerTitle],
});
XLSX.utils.sheet_add_json(sheet, data, { origin: 'A3' });
XLSX.utils.book_append_sheet(workbook, sheet);
XLSX.writeFile(workbook, 'fileName.xls');

where headerTitle name is the header column, data is the excel file data in array forma