TypeError: undefined.trim() when reading a t="str" cell with an empty value
This is the Claude supported analysis which seems to match the error we are observing:
Description
Since 9.3.0, reading certain .xlsx files throws TypeError: Cannot read properties of undefined (reading 'trim'). It still occurs in 9.3.3. Version 9.2.0 reads the same files correctly, so this is a regression introduced by the DOM → SAX XML parser rewrite in 9.3.0. (It appears to be a separate regression from the non-ASCII one fixed in 9.3.3 / MR #10 (closed).)
Stack trace:
TypeError: Cannot read properties of undefined (reading 'trim') at parseString (…/xlsx/parseCellValue.js) at parseCellValue (…/xlsx/parseCellValue.js) at parseCell (…/xlsx/parseCell.js)
Trigger: a cell of type t="str" (a formula whose computed result is a string) whose <v> is empty or missing — e.g. a formula returning "". Minimal worksheet cell that reproduces it:
xml
<c r="A2" t="str"><f>IF(TRUE,"","x")</f><v></v></c>
Expected: the cell is read as empty (null), as in 9.2.0.
Actual: .trim() is called on undefined and the whole read fails.
Root cause: in parseCell.js, the cell state initializes value: undefined and onTextInCell does state.value = text. For an empty/absent <v>, no text event fires, so value stays undefined and is passed into parseCellValue → parseString, which calls value.trim() unguarded (parseCellValue.js, str/s branches).
Suggested fix: guard parseString against a non-string value (e.g. treat undefined as empty/null), or default the captured cell value to ''.