MCPcopy
hub / github.com/exceljs/exceljs / store

Method store

lib/doc/table.js:180–234  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

178 }
179
180 store() {
181 // where the table needs to store table data, headers, footers in
182 // the sheet...
183 const assignStyle = (cell, style) => {
184 if (style) {
185 Object.keys(style).forEach(key => {
186 cell.style[key] = style[key];
187 });
188 }
189 };
190
191 const {worksheet, table} = this;
192 const {row, col} = table.tl;
193 let count = 0;
194 if (table.headerRow) {
195 const r = worksheet.getRow(row + count++);
196 table.columns.forEach((column, j) => {
197 const {style, name} = column;
198 const cell = r.getCell(col + j);
199 cell.value = name;
200 assignStyle(cell, style);
201 });
202 }
203 table.rows.forEach(data => {
204 const r = worksheet.getRow(row + count++);
205 data.forEach((value, j) => {
206 const cell = r.getCell(col + j);
207 cell.value = value;
208
209 assignStyle(cell, table.columns[j].style);
210 });
211 });
212
213 if (table.totalsRow) {
214 const r = worksheet.getRow(row + count++);
215 table.columns.forEach((column, j) => {
216 const cell = r.getCell(col + j);
217 if (j === 0) {
218 cell.value = column.totalsRowLabel;
219 } else {
220 const formula = this.getFormula(column);
221 if (formula) {
222 cell.value = {
223 formula: column.totalsRowFormula,
224 result: column.totalsRowResult,
225 };
226 } else {
227 cell.value = null;
228 }
229 }
230
231 assignStyle(cell, column.style);
232 });
233 }
234 }
235
236 load(worksheet) {
237 // where the table will read necessary features from a loaded sheet

Callers 2

constructorMethod · 0.95
commitMethod · 0.95

Calls 4

getFormulaMethod · 0.95
getRowMethod · 0.65
forEachMethod · 0.65
getCellMethod · 0.65

Tested by

no test coverage detected