MCPcopy
hub / github.com/exceljs/exceljs / prepare

Method prepare

lib/xlsx/xform/sheet/cell-xform.js:56–128  ·  view source on GitHub ↗
(model, options)

Source from the content-addressed store, hash-verified

54 }
55
56 prepare(model, options) {
57 const styleId = options.styles.addStyleModel(model.style || {}, getEffectiveCellType(model));
58 if (styleId) {
59 model.styleId = styleId;
60 }
61
62 if (model.comment) {
63 options.comments.push({...model.comment, ref: model.address});
64 }
65
66 switch (model.type) {
67 case Enums.ValueType.String:
68 case Enums.ValueType.RichText:
69 if (options.sharedStrings) {
70 model.ssId = options.sharedStrings.add(model.value);
71 }
72 break;
73
74 case Enums.ValueType.Date:
75 if (options.date1904) {
76 model.date1904 = true;
77 }
78 break;
79
80 case Enums.ValueType.Hyperlink:
81 if (options.sharedStrings && model.text !== undefined && model.text !== null) {
82 model.ssId = options.sharedStrings.add(model.text);
83 }
84 options.hyperlinks.push({
85 address: model.address,
86 target: model.hyperlink,
87 tooltip: model.tooltip,
88 });
89 break;
90
91 case Enums.ValueType.Merge:
92 options.merges.add(model);
93 break;
94
95 case Enums.ValueType.Formula:
96 if (options.date1904) {
97 // in case valueType is date
98 model.date1904 = true;
99 }
100
101 if (model.shareType === 'shared') {
102 model.si = options.siFormulae++;
103 }
104
105 if (model.formula) {
106 options.formulae[model.address] = model;
107 } else if (model.sharedFormula) {
108 const master = options.formulae[model.sharedFormula];
109 if (!master) {
110 throw new Error(
111 `Shared Formula master must exist above and or left of clone for cell ${model.address}`
112 );
113 }

Callers

nothing calls this directly

Calls 5

getEffectiveCellTypeFunction · 0.85
addMethod · 0.65
expandToAddressMethod · 0.65
addStyleModelMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected