How to use correctly Spreadsheet::WriteExcel to convert xml to xls


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to use correctly Spreadsheet::WriteExcel to convert xml to xls
Prev   Next
# 1  
Old 10-11-2011
How to use correctly Spreadsheet::WriteExcel to convert xml to xls

Hi to all,

I want to convert xml file to binary Excel file, after googling for a while, I found cpan tool "Spreadsheet::WriteExcel::FromXML". I installed both,
Spreadsheet::WriteExcel and Spreadsheet::WriteExcel::FromXML.

To test Spreadsheet::WriteExcel I executed a example script that comes within it, "a_simple.pl" and works.

But the codes below intended to use convert xml to xls don't work for me.

I've been trying to follow 2 examples of xml to xls:
This code below
Ref: http://search.cpan.org/~rbo/Excel-Template-0.33/lib/Excel/Template.pm
Code:
  #!/usr/bin/perl -w

  use strict;

  use Excel::Template;

  # Create the Excel template
  my $template = Excel::Template->new(
      filename => 'test.xml',
  );
  # Add a few parameters
  $template->param(
      HOME => $ENV{HOME},
      PATH => $ENV{PATH},
  );
  $template->write_file('test.xls');

and the options from the code below:
Ref: http://search.cpan.org/dist/Spreadsheet-WriteExcel-FromXML/lib/Spreadsheet/WriteExcel/FromXML.pm
Code:
  use strict;
  use warnings;
  use Spreadsheet::WriteExcel::FromXML;
  my $fromxml = Spreadsheet::WriteExcel::FromXML->new( "file.xml" );
  $fromxml->parse;
  $fromxml->buildSpreadsheet;
  $fromxml->writeFile("file.xls");
  # or
  my $data = $fromxml->getSpreadsheetData;
  # then write $data to a file...or do with it as you wish

  # or, even simpler:
  my $data = Spreadsheet::WriteExcel::FromXML->BuildSpreadsheet( "file.xml" );

  # or, even simpler:
  Spreadsheet::WriteExcel::FromXML->XMLToXLS( "file.xml", "file.xls" );

Follow the 1rst example, the test.xml is as simple as:
Code:
  <workbook>
      <worksheet name="tester">
          <cell text="$HOME" />
          <cell text="$PATH" />
      </worksheet>
  </workbook>

and I get the following errors when I run the 2nd code:
Code:
./xml_to_xls.pl # I only trying the lines in red in code above
Must define a title attribute for worksheet!
 at /usr/local/share/perl/5.10.1/Spreadsheet/WriteExcel/FromXML.pm line 248
    Spreadsheet::WriteExcel::FromXML::_processTree('Spreadsheet::WriteExcel::FromXML=HASH(0x9f2a818)', 
'ARRAY(0xa4b5340)', 'worksheet', 'SCALAR(0xa4a08d0)', 'SCALAR(0xa4a08f0)', undef, undef) called at /usr/local/share/perl/5.10.1/
Spreadsheet/WriteExcel/FromXML.pm line 328
    Spreadsheet::WriteExcel::FromXML::_processTree('Spreadsheet::WriteExcel::FromXML=HASH(0x9f2a818)', 'ARRAY(0xa4b5270)', 
'workbook', 'SCALAR(0xa4a08d0)', 'SCALAR(0xa4a08f0)') called at /usr/local/share/perl/5.10.1/Spreadsheet/WriteExcel/FromXML.pm line 186
    Spreadsheet::WriteExcel::FromXML::parse('Spreadsheet::WriteExcel::FromXML=HASH(0x9f2a818)') called at ./xml_to_xls.pl line 7

May somebody please help me saying me how to test/use correctly the module Spreadsheet::WriteExcel::FromXML or
Spreadsheet::WriteExcel in order to convert XML files to Excel XLS files?

Thanks in advance


---------- Post updated at 03:51 PM ---------- Previous update was at 05:32 AM ----------

May somebody help me with this

Thanks in advance.

Last edited by Ophiuchus; 10-11-2011 at 06:39 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Spreadsheet::WriteExcel::FromXML question(s)

Hi All, attempting to use this pm to import large xml file directly into excel and getting some errors. Using the generic example: #!/usr/bin/perl -w use strict; use warnings; use Spreadsheet::WriteExcel::FromXML; my $fromxml =... (1 Reply)
Discussion started by: garboon
1 Replies

2. Shell Programming and Scripting

xml to xls

looking for a script to convert from xml file format to xls file format incoming file in xml should be converted to xls file (3 Replies)
Discussion started by: userraone
3 Replies

3. Shell Programming and Scripting

problem with "merge_range" in Spreadsheet::WriteExcel" module

Any one having idea that,How to copy merged cell from existing excel file to new excel file? Note : Is there any bug in module(Spreadsheet::WriteExcel or Spreadsheet::ParseExcel) itself ? Thanks, kavi (0 Replies)
Discussion started by: kavi.mogu
0 Replies

4. Shell Programming and Scripting

how to convert .xls to .csv

Hi, I have problem..How to convert .xls file to .csv.. Plz help me for this problem.. (1 Reply)
Discussion started by: varma457
1 Replies

5. Shell Programming and Scripting

How to input .txt file into .xls spreadsheet

I need to take the totals from my script and input them into a excel spreadsheet. Right now, I just copy and paste. Is there an easier way? 3906 is the total jobs in ABEND state 4005 is the total jobs in SUCC state 1050 is the total jobs in HOLD state (1 Reply)
Discussion started by: wereyou
1 Replies
Login or Register to Ask a Question