Question

I am writing a Perl/Tk script which displays Excel worksheets using the ss2tk example script from the Spreadsheet::Read module. It does not round off two decimal places but the function from Spreadsheet::XLSX::Utility2007 does round off to two decimal places. Why? I'm trying to use that second function as a feature of my program to offer conversion of the displayed worksheets to CSV files.

Was it helpful?

Solution

I see you were able to get an answer over at PerlMonks with the help of frieduck (any relation to friedo?), so I'm linking it up for the benefit of SO folks.

To summarize, basically it turned out that the internals of Spreadsheet::XLSX::Utility2007 were automatically applying a 2-decimal place format when retrieving the cell values. The two workarounds proposed were:

  1. Changing the way the module generates cell types (make it treat them all as defaults) by modifying XLSX internals.
  2. Changing the way the module treats the cells loaded from the spreadsheet (treating them as having the unformatted value from the original spreadsheet), also by modifying internals.

Either way, it was also mentioned that you'd probably be best off defining a local sub to do perform the modified behavior, so that there aren't any nasty surprises resulting from changing the module in place.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top