MCPcopy
hub / github.com/exceljs/exceljs / addWorksheet

Method addWorksheet

lib/doc/workbook.js:54–94  ·  view source on GitHub ↗
(name, options)

Source from the content-addressed store, hash-verified

52 }
53
54 addWorksheet(name, options) {
55 const id = this.nextId;
56
57 // if options is a color, call it tabColor (and signal deprecated message)
58 if (options) {
59 if (typeof options === 'string') {
60 // eslint-disable-next-line no-console
61 console.trace(
62 'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { argb: "rbg value" } }'
63 );
64 options = {
65 properties: {
66 tabColor: {argb: options},
67 },
68 };
69 } else if (options.argb || options.theme || options.indexed) {
70 // eslint-disable-next-line no-console
71 console.trace(
72 'tabColor argument is now deprecated. Please use workbook.addWorksheet(name, {properties: { tabColor: { ... } }'
73 );
74 options = {
75 properties: {
76 tabColor: options,
77 },
78 };
79 }
80 }
81
82 const lastOrderNo = this._worksheets.reduce((acc, ws) => ((ws && ws.orderNo) > acc ? ws.orderNo : acc), 0);
83 const worksheetOptions = Object.assign({}, options, {
84 id,
85 name,
86 orderNo: lastOrderNo + 1,
87 workbook: this,
88 });
89
90 const worksheet = new Worksheet(worksheetOptions);
91
92 this._worksheets[id] = worksheet;
93 return worksheet;
94 }
95
96 removeWorksheetEx(worksheet) {
97 delete this._worksheets[worksheet.id];

Callers 15

mainFunction · 0.95
testFunction · 0.95
createSimpleWorkbookFunction · 0.95
readMethod · 0.45
test-protection.jsFile · 0.45
test-issue-581.jsFile · 0.45
test-hyperlink.jsFile · 0.45

Calls 1

assignMethod · 0.80

Tested by 2

testFunction · 0.76
createSimpleWorkbookFunction · 0.76