Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Created Unassigned: Addition of PX as a knownUnit in XLWorkSheet_Load.cs [9382]

$
0
0

I came across an Excel file (I think from 2003 originally and re-saved as MS Office 2013 XLSX) which hit the GetPtValue private method in the XLWorksheet_Load.cs file and the string was "62px". As "px" is not in the knownUnits dictionary this progressed on to fail with a Double parse error.

Can I suggest:

1) Add "px" with an averagely acceptable conversion factor of 1.3 (it actually varies depending on user screen resolution - but I can't see it being of any benefit to react to that).

private readonly Dictionary<string, double> knownUnits = new Dictionary<string, double>
{
{"pt", 1.0},
{"in", 72.0},
{"mm", 72.0/25.4},
{"px", 1.3333333}
};

2) Handle the Double parse in GetPtValue with a Try Parse and default some nominal value . It may mean after resaving some positioning is complete wrong, but this seems better than failing to an exception.


Good work! Keep it up.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>