Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Differnece between Spreadsheet::ParseXLSX and Spreadsheet::ParseExcel

by Sonali (Novice)
on Mar 27, 2017 at 06:15 UTC ( [id://1186036]=perlquestion: print w/replies, xml ) Need Help??

Sonali has asked for the wisdom of the Perl Monks concerning the following question:

Hello PerlMonks,

I have been trying to parse a .xls and another .xlsx file using the Spreadsheet::ParseExcel and Spreadsheet::ParseXLSX modules

When I dump the contents of both the files into two different files, the structure of the hash generated is very different, I wanted to know what exactly is the difference between the two parsers.

My code goes like this,

#!/usr/local/bin/perl use warnings; use strict; use Spreadsheet::XLSX; use Spreadsheet::ParseExcel; use Data::Dumper; my $Output_FileName = 'outfile.txt'; my $Output_FileName1 = 'outfile1.txt'; my $excel = Spreadsheet::XLSX -> new ('book1.xlsx'); my $parser = Spreadsheet::ParseExcel->new(); my $workbook = $parser->parse('book2.xls'); open(my $FH, '>', $Output_FileName) or die "Could not open file '$Outp +ut_FileName' $!"; print $FH Dumper(\$excel); close $FH; open(my $FH1, '>', $Output_FileName1) or die "Could not open file '$Ou +tput_FileName1' $!"; print $FH1 Dumper(\$excel); close $FH1;

Is there a better way to dump both the files so that I can compare the two dumped files? In my case the files were mostly full of information like font etc...

Thank you!

  • Comment on Differnece between Spreadsheet::ParseXLSX and Spreadsheet::ParseExcel
  • Download Code

Replies are listed 'Best First'.
Re: Differnece between Spreadsheet::ParseXLSX and Spreadsheet::ParseExcel
by 1nickt (Canon) on Mar 27, 2017 at 12:37 UTC

    Hello Sonali,

    I cannot advise on spreadsheet issues, but you may find that it's easier to compare hashes dumped with Data::Dumper if you use its Sortkeys flag:

    use Data::Dumper; $Data::Dumper::Sortkeys = 1; print Dumper \%hash; ...
    The above will sort the keys according to Perl's default sort order. You can also pass a subroutine reference as the value of $Data::Dumper::Sortkeys to control the sort or even limit the keys that are dumped. See Configuration Variables or Methods for more information.

    Hope this helps!


    The way forward always starts with a minimal test.
Re: Differnece between Spreadsheet::ParseXLSX and Spreadsheet::ParseExcel
by madtoperl (Hermit) on Mar 27, 2017 at 09:19 UTC
Re: Differnece between Spreadsheet::ParseXLSX and Spreadsheet::ParseExcel
by Anonymous Monk on Mar 27, 2017 at 06:24 UTC

    Hi,

    Yes, use smaller(nano) files so that Dumper differences are easier to see :)

    Or, Dumper smaller chunks of each file so they're easier to compare

    But,

    What are you trying to find out?

    Spreadsheet::ParseExcel seems to wants you to use the API ... where as the other module doesn't :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1186036]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 15:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found