1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
| var Excel = require("exceljs");
var workbook = new Excel.Workbook();
var worksheet = workbook.addWorksheet("第一个标签");
var worksheet2 = workbook.addWorksheet("第二个标签", { properties: { tabColor: { argb: "FFC0000" } } });
worksheet.columns = [{ header: 'Rating Period', key: 'id', width: 38 }, { header: 'Name', key: 'name', width: 32, }, { header: 'D.O.B.', key: 'DOB', width: 10, style: { numFmt: 'dd/mm/yyyy' } } ];
worksheet.addRow({ id: 1, name: 'John Doe', dob: new Date(1970, 1, 1) }); worksheet.addRow({ id: 2, name: 'Jane Doe', dob: new Date(1965, 1, 7) });
worksheet.getCell(1).value = "Z";
worksheet.getCell('A6').value = "1989";
worksheet.mergeCells('A4:A7');
worksheet.mergeCells('A10', 'B11');
worksheet.getCell('A1').value = 1.6; worksheet.getCell('A1').numFmt = '# ?/?';
worksheet.getCell('B1').value = 0.016; worksheet.getCell('B1').numFmt = '0.00%';
worksheet.getCell('A3').font = { name: 'Comic Sans MS', family: 4, size: 16, underline: true, bold: true, }; worksheet.getCell('A3').value = "测试字体"
worksheet.getCell('A1').alignment = { vertical: 'top', horizontal: 'left' }; worksheet.getCell('B1').alignment = { vertical: 'middle', horizontal: 'center' }; worksheet.getCell('C1').alignment = { vertical: 'bottom', horizontal: 'right' };
worksheet.getCell('A1').border = { top: { style: 'double', color: { argb: 'FF00FF00' } }, left: { style: 'double' }, bottom: { style: 'thin' }, right: { style: 'thin' } };
worksheet.getCell('A1').fill = { type: 'pattern', pattern: 'solid', bgColor: { argb: 'FF0000FF' } };
workbook.xlsx.writeFile("second.xlsx").then(function () { console.log("saved"); });
|