MCPcopy
hub / github.com/exceljs/exceljs / toModel

Method toModel

lib/doc/column.js:265–293  ·  view source on GitHub ↗
(columns)

Source from the content-addressed store, hash-verified

263 // static functions
264
265 static toModel(columns) {
266 // Convert array of Column into compressed list cols
267 const cols = [];
268 let col = null;
269 if (columns) {
270 columns.forEach((column, index) => {
271 if (column.isDefault) {
272 if (col) {
273 col = null;
274 }
275 } else if (!col || !column.equivalentTo(col)) {
276 col = {
277 min: index + 1,
278 max: index + 1,
279 width: column.width !== undefined ? column.width : DEFAULT_COLUMN_WIDTH,
280 style: column.style,
281 isCustomWidth: column.isCustomWidth,
282 hidden: column.hidden,
283 outlineLevel: column.outlineLevel,
284 collapsed: column.collapsed,
285 };
286 cols.push(col);
287 } else {
288 col.max = index + 1;
289 }
290 });
291 }
292 return cols.length ? cols : undefined;
293 }
294
295 static fromModel(worksheet, cols) {
296 cols = cols || [];

Callers 4

modelMethod · 0.80
_writeColumnsMethod · 0.80
parseOpenMethod · 0.80
column.spec.jsFile · 0.80

Calls 3

forEachMethod · 0.65
equivalentToMethod · 0.65
pushMethod · 0.45

Tested by

no test coverage detected