Summary
Adopt upstream PR exceljs#2956 to fix handling of non-numeric values in excelToDate().
Currently, when a non-numeric value is passed to excelToDate() (e.g., when a cell has date formatting but contains text), it returns "Invalid Date" which gets converted to NaN and causes Excel to show warnings when opening the file.
Upstream PR
Changes
File modified:
lib/utils/utils.js - Add validation check in excelToDate() (1 line)
Total: 1 addition, 0 deletions
Bug Description
When a cell has date formatting but contains a non-numeric value, excelToDate() tries to convert it and returns "Invalid Date", which persists as NaN in the Excel file.
Current behavior:
excelToDate(v, date1904) {
const millisecondSinceEpoch = Math.round((v - 25569 + ...) * 24 * 3600 * 1000);
return new Date(millisecondSinceEpoch); // Returns Invalid Date for non-numeric v
}
Fixed behavior:
excelToDate(v, date1904) {
if (!Number.isFinite(v)) return v; // Return original value if not numeric
const millisecondSinceEpoch = Math.round((v - 25569 + ...) * 24 * 3600 * 1000);
return new Date(millisecondSinceEpoch);
}
Value Proposition
- Low Risk - Single line validation check
- Bug Fix - Prevents Excel warnings on file open
- User Experience - Eliminates annoying error popups
Testing Plan
Summary
Adopt upstream PR exceljs#2956 to fix handling of non-numeric values in excelToDate().
Currently, when a non-numeric value is passed to excelToDate() (e.g., when a cell has date formatting but contains text), it returns "Invalid Date" which gets converted to NaN and causes Excel to show warnings when opening the file.
Upstream PR
Changes
File modified:
lib/utils/utils.js- Add validation check in excelToDate() (1 line)Total: 1 addition, 0 deletions
Bug Description
When a cell has date formatting but contains a non-numeric value, excelToDate() tries to convert it and returns "Invalid Date", which persists as NaN in the Excel file.
Current behavior:
Fixed behavior:
Value Proposition
Testing Plan