MCPcopy
hub / github.com/exceljs/exceljs / parse

Method parse

lib/stream/xlsx/worksheet-reader.js:115–371  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113 }
114
115 async *parse() {
116 const {iterator, options} = this;
117 let emitSheet = false;
118 let emitHyperlinks = false;
119 let hyperlinks = null;
120 switch (options.worksheets) {
121 case 'emit':
122 emitSheet = true;
123 break;
124 case 'prep':
125 break;
126 default:
127 break;
128 }
129 switch (options.hyperlinks) {
130 case 'emit':
131 emitHyperlinks = true;
132 break;
133 case 'cache':
134 this.hyperlinks = hyperlinks = {};
135 break;
136 default:
137 break;
138 }
139 if (!emitSheet && !emitHyperlinks && !hyperlinks) {
140 return;
141 }
142
143 // references
144 const {sharedStrings, styles, properties} = this.workbook;
145
146 // xml position
147 let inCols = false;
148 let inRows = false;
149 let inHyperlinks = false;
150
151 // parse state
152 let cols = null;
153 let row = null;
154 let c = null;
155 let current = null;
156 for await (const events of parseSax(iterator)) {
157 const worksheetEvents = [];
158 for (const {eventType, value} of events) {
159 if (eventType === 'opentag') {
160 const node = value;
161 if (emitSheet) {
162 switch (node.name) {
163 case 'cols':
164 inCols = true;
165 cols = [];
166 break;
167 case 'sheetData':
168 inRows = true;
169 break;
170
171 case 'col':
172 if (inCols) {

Callers 2

readMethod · 0.95

Calls 5

expandRowMethod · 0.65
getCellMethod · 0.65
pushMethod · 0.45
getStyleModelMethod · 0.45
fromModelMethod · 0.45

Tested by

no test coverage detected