Click the download button to check the downloaded Excel file.
1import { FileBuilder, SheetBuilder, CellBuilder } from 'excel-build';
2
3 function App() {
4 const makeExcel = () => {
5 const excelFile = new FileBuilder('Example');
6 const data = [
7 ['1', 'soohyun', 'sasha1107@naver.com', '01012345678', 'FE'],
8 ['2', 'sasha', 'sasha981107@gmail.com', '01087654321', 'BE'],
9 ];
10
11 const sheet1 = new SheetBuilder('sheet_1').appendCustomRow(
12 data[0].map((item) =>
13 new CellBuilder(item)
14 .setFontSize(20)
15 .setFontColor('#FFFFFF')
16 .setBackgroundColor('#555555')
17 .setFontItalic()
18 .build()
19 )
20 );
21 const sheet2 = new SheetBuilder('sheet_2')
22 .appendThead(['id', 'name', 'email', 'phone', 'department'])
23 .appendTbody(data)
24 .mergeCell([0, 3], [4, 3]);
25
26 excelFile.addSheet(sheet1).addSheet(sheet2).download();
27 }
28
29 return (
30 <button onClick={makeExcel}>
31 Download
32 </button>
33 );
34 }