In case number_format() is called on a format that does not have a value format set, numberformat() calls d->number_format_id.get() on an invalid number_formatid or dereferences d->parent->number_formats.end() causing a crash.
This can happen when calling cell::is_date() on a cell that has type 'number' without a number format but some other styling set.
This might never occur in spreadsheet files created by commercial applications but xlnt certainly allows to create such a file.
We therefore fix number_format by returning the general number format as a fallback.
Additionally, consider to add a method format::has_number_format() and change cell::is_date() accordingly.
Attached there is a test file were the problem occurs when cell::is_date() is called on cell A1.
Test.xlsx
In case number_format() is called on a format that does not have a value format set, numberformat() calls d->number_format_id.get() on an invalid number_formatid or dereferences d->parent->number_formats.end() causing a crash.
This can happen when calling cell::is_date() on a cell that has type 'number' without a number format but some other styling set. This might never occur in spreadsheet files created by commercial applications but xlnt certainly allows to create such a file. We therefore fix number_format by returning the general number format as a fallback. Additionally, consider to add a method format::has_number_format() and change cell::is_date() accordingly.
Attached there is a test file were the problem occurs when cell::is_date() is called on cell A1. Test.xlsx