Epplus version
8.6.0.0
Description
There is a case-sensitivity mismatch inside ExcelChartAxisStandard (under OfficeOpenXml.Drawing.Chart) when reading and writing the MajorTickMark and MinorTickMark properties:
- Write (Setter): Setting the value (e.g.
eAxisTickMark.In or eAxisTickMark.Out) lowercases the enum string and writes it to the XML node:
value.ToString().ToLower(CultureInfo.InvariantCulture) => Writes "in", "out", or "none" into the XML.
- Read (Getter): The getter reads the raw string (e.g.
"in") but parses it case-sensitively back to the eAxisTickMark enum (which expects capitalized members: In, Out, None, Cross):
return (eAxisTickMark)Enum.Parse(typeof(eAxisTickMark), v);
- The Consequence: Because
"in" does not match "In" case-sensitively, Enum.Parse throws an exception, catches it, and always falls back to returning the default Cross.
This makes it impossible to read back any value set on MajorTickMark or MinorTickMark unless it is Cross.
Proposed fix
Update Enum.Parse inside ExcelChartAxisStandard.cs's MajorTickMark and MinorTickMark properties to be case-insensitive by passing true as the third parameter:
// MajorTickMark Getter
return (eAxisTickMark)Enum.Parse(typeof(eAxisTickMark), v, true);
// MinorTickMark Getter
return (eAxisTickMark)Enum.Parse(typeof(eAxisTickMark), v, true);
This brings these properties into alignment with all other enum parsing calls inside ExcelChartAxisStandard.cs (which already use true for case-insensitivity, e.g., eTickLabelPosition, eCrosses, eCrossBetween, etc.).
PR ready for review/merge.
Epplus version
8.6.0.0
Description
There is a case-sensitivity mismatch inside
ExcelChartAxisStandard(underOfficeOpenXml.Drawing.Chart) when reading and writing theMajorTickMarkandMinorTickMarkproperties:eAxisTickMark.InoreAxisTickMark.Out) lowercases the enum string and writes it to the XML node:value.ToString().ToLower(CultureInfo.InvariantCulture)=> Writes"in","out", or"none"into the XML."in") but parses it case-sensitively back to theeAxisTickMarkenum (which expects capitalized members:In,Out,None,Cross):return (eAxisTickMark)Enum.Parse(typeof(eAxisTickMark), v);"in"does not match"In"case-sensitively,Enum.Parsethrows an exception, catches it, and always falls back to returning the defaultCross.This makes it impossible to read back any value set on
MajorTickMarkorMinorTickMarkunless it isCross.Proposed fix
Update
Enum.ParseinsideExcelChartAxisStandard.cs'sMajorTickMarkandMinorTickMarkproperties to be case-insensitive by passingtrueas the third parameter:This brings these properties into alignment with all other enum parsing calls inside
ExcelChartAxisStandard.cs(which already usetruefor case-insensitivity, e.g.,eTickLabelPosition,eCrosses,eCrossBetween, etc.).PR ready for review/merge.