Whilst not a bug per se, this can cause problems for someone doing this:
double? bottomMargin = default;
ws.PrinterSettings.BottomMargin = bottomMargin ?? ws.PrinterSettings.BottomMargin;
Since bottomMargin has no value the return value from ws.PrinterSettings.BottomMargin will be assigned to itself, which probably makes sense. However since the getter of these properties reads directly from the xml via the GetXmlNodeDouble method they will return double.NaN if there is no value set. And this causes "NaN" to be written to the xml and causes a corrupt workbook.
Possible improvements
- Improve the xml documents for the properties in the PrinterSettings class and add the information that they return NaN if there is no value set.
- We could perhaps ignore NaN values in the setters - if the current value is Null and the new value is double.NaN don't write the new value to the xml.
Whilst not a bug per se, this can cause problems for someone doing this:
Since
bottomMarginhas no value the return value fromws.PrinterSettings.BottomMarginwill be assigned to itself, which probably makes sense. However since the getter of these properties reads directly from the xml via theGetXmlNodeDoublemethod they will returndouble.NaNif there is no value set. And this causes "NaN" to be written to the xml and causes a corrupt workbook.Possible improvements