开发者

Why are values being truncated while reading an Excel 2007 (.xlsx) file in Perl?

I am reading an .xls file using Spreadsheet::ParseExcel and was able to get data as is.

But,when reading an .xlsx file using Spreadsheet::XLSX, the read values are truncated.

E.g., 2.4578 in .xls and .xlsx file is read as 2.4578 and 2.45开发者_开发技巧, respectively.

Please suggest why .xlsx file data is corrupted.


I created a simple workbook containing one sheet and only the value 2.4578 in A1 and ran the following script:

use Spreadsheet::XLSX;

my $excel = Spreadsheet::XLSX->new('Book1.xlsx');

my ($sheet) = @{ $excel->{Worksheet} };

print $sheet->{Cells}[0][0]{Val}, "\n";

Output:

C:\Temp> x
2.4578000000000002

So, in this simple case, everything seems to be OK.

If you can post a short, self-contained example that exhibits the problem and a small sample .xlsx file which we can look at, we would have a better chance of identifying the problem.


Try $cell->{Val} for the unformatted raw value instead of $cell->Value() for the Excel formatted value.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜