DEMO-time!

I had a friend with Windows and some recentish MS-Office create me an xlsx with just one single cell filled with the value 0.9888 and then put that in sandbox/x-0.9888.xlsx

$ perl -Mblib -MDP -MSpreadsheet::Read -we'DDumper ReadData ("sandbox/ +x-0.9888.xlsx")' [ { error => undef, parser => 'Spreadsheet::ParseXLSX', sheet => { Blad1 => 1 }, sheets => 3, type => 'xlsx', version => '0.17' }, { A1 => '0.98880000000000001', attr => [], cell => [ [], [ undef, '0.98880000000000001' ] ], label => 'Blad1', maxcol => 1, maxrow => 1, merged => [] } ] $ env SPREADSHEET_READ_XLSX=Spreadsheet::XLSX perl -Mblib -MDP -MSprea +dsheet::Read -we'DDumper ReadData ("sandbox/x-0.9888.xlsx")' [ { error => undef, parser => 'Spreadsheet::XLSX', sheet => { Blad1 => 1 }, sheets => 3, type => 'xlsx', version => '0.13' }, { A1 => '0.99', attr => [], cell => [ [], [ undef, '0.98880000000000001' ] ], label => 'Blad1', maxcol => 1, maxrow => 1, merged => [] } ] $ env SPREADSHEET_READ_XLSX=Spreadsheet::XLSX::Reader::LibXML perl -Mb +lib -MDP -MSpreadsheet::Read -we'DDumper ReadData ("sandbox/x-0.9888. +xlsx")' XLSX parser cannot parse data: at -e line 1.

I expected that last error: it is the formatter for that module that currently causes integration problems.

I used the development folder, as choosing your own parser is new and not yet released.

This clearly shows the influence of the formatter used in the underlying parser.

I get consistent results for Spreadsheet::ParseXLSX on Linux, AIX and HP-UX. On Windows, I get:

C:\Tmp> perl -MDP -MSpreadsheet::Read -we"DDumper ReadData ('x-0.9888. +xlsx')" [ { error => undef, parser => 'Spreadsheet::ParseXLSX', sheet => { Blad1 => 1 }, sheets => 3, type => 'xlsx', version => '0.17' }, { A1 => '0.9888', attr => [], cell => [ [], [ undef, '0.9888' ] ], label => 'Blad1', maxcol => 1, maxrow => 1, merged => [] } ]

If I unzip the file and then show the stored data:

$ xml_pp < xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet mc:Ignorable="x14ac" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006 +/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatib +ility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2 +006/relationships" xmlns:x14ac="http://schemas.microsoft.com/office/spreadshee +tml/2009/9/ac"> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15" x14ac:dyDescent="0.25"/> <sheetData> <row r="1" spans="1:1" x14ac:dyDescent="0.25"> <c r="A1"> <v>0.98880000000000001</v> </c> </row> </sheetData> <pageMargins bottom="0.75" footer="0.3" header="0.3" left="0.7" righ +t="0.7" top="0.75"/> </worksheet> $

It clearly shows that Excel stored 0.98880000000000001 in the spreadsheet. (For all that now want to blame the formatter, using cat showed the same content, but that would be way too wide a line to neatly show in this forum).


Enjoy, Have FUN! H.Merijn

In reply to Re: Spreadsheet::Read module is rounding the decimals in XLSX file by Tux
in thread Spreadsheet::Read module is rounding the decimals in XLSX file by char_perl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.