@@ -47,21 +47,28 @@ class ValueComparator {
4747 * @returns {boolean } true if values are equal, false otherwise
4848 */
4949 areEqual ( valA : unknown , valB : unknown ) : boolean {
50- if ( valA == null && valB == null ) return true
50+ // NORMALIZE NULL
51+ if ( valA == null ) {
52+ valA = null
53+ }
5154
52- // Handle number comparison with potential floating point precision issues
53- if ( typeof valA === 'number' && typeof valB === 'number' ) {
54- if ( isNaN ( valA ) && isNaN ( valB ) ) return true
55- return Math . abs ( valA - valB ) < this . epsilon
55+ if ( valB == null ) {
56+ valB = null
5657 }
5758
58- // Handle error comparison
59+ // NORMALIZE ERRORS
5960 if ( valA instanceof DetailedCellError ) {
60- valA = { error : valA . value }
61+ valA = valA . value
6162 }
6263
6364 if ( valB instanceof DetailedCellError ) {
64- valB = { error : valB . type }
65+ valB = valB . value
66+ }
67+
68+ // Handle number comparison with potential floating point precision issues
69+ if ( typeof valA === 'number' && typeof valB === 'number' ) {
70+ if ( isNaN ( valA ) && isNaN ( valB ) ) return true
71+ return Math . abs ( valA - valB ) < this . epsilon
6572 }
6673
6774 // Handle object comparison (dates, etc.)
@@ -191,11 +198,7 @@ function convertXlsxWorkbookToFormulasAndValuesArrays(workbook: Workbook): [Shee
191198
192199 row . eachCell ( ( cell : Cell ) => {
193200 const cellData = cell . formula ? `=${ cell . formula } ` : cell . value as RawCellContent
194- const cellValue = ( cell . value && typeof cell . value === 'object' && 'result' in cell . value && cell . value . result != null
195- ? cell . value . result
196- : cell . value && typeof cell . value === 'object' && 'formula' in cell . value && cell . value . formula != null
197- ? 0
198- : cell . value ) as RawCellContent
201+ const cellValue = ( cell . value ?. result ?. error ?? cell . value ?. result ?? ( cell . value ?. formula != null ? 0 : cell . value ) ) as RawCellContent
199202 rowData . push ( cellData )
200203 rowReadValues . push ( cellValue )
201204 } )
0 commit comments