1

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 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.