I successfully parsed an xls
file using Spreadsheet::ParseExcel::SaveParser
and modified it with Spreadsheet::WriteExcel
.
However working with xlsx
file is a whole different thing.
I am trying to figure out how to work with Spreadsheet::XLSX
for parsing and how to make it work with Excel::Writer::XLSX
. Spreadsheet::ParseExcel::SaveParser
has a SaveAs()
method that makes it possible to apply Spreadsheet::WriteExcel
methods on the parsed xml
file, but I don't understand how to make it work with xlsx file
edit:
when using Spreadsheet::ParseExcel::SaveParser
and Spreadsheet::WriteExcel
I can write:
#!/usr/bin/perl -w
use strict;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseExcel::SaveParser;
# Open the template with SaveParser
my $parser = new Spreadsheet::ParseExcel::SaveParser;
my $template = $parser->Parse('template.xls');
# Rewrite the file or save as a new file
$workbook = $template->SaveAs('new.xls');
# Use Spreadsheet::WriteExcel methods
my $worksheet = $workbook->sheets(0);
$worksheet->write($row+2, $col, "World2");
$workbook->close();
I would like to do the same with xlsx
files. therefore I'm trying to use Spreadsheet::XLSX
and Excel::Writer::XLSX
.
Instead of
my $parser = new Spreadsheet::ParseExcel::SaveParser;
my $template = $parser->Parse('template.xls');
I use
my $excel = Spreadsheet::XLSX -> new ('test.xlsx');
Now, after parsing the xlsx
file I would like to add some data to it and I don't know how to do it.
As you can see above when using Spreadsheet::ParseExcel::SaveParser
I used SaveAs()
function,
but Spreadsheet::XLSX
dosn't have a SaveAs()
method. So how do I add data to parsed xlsx
file?
I could not find an answer to my question in this link.
Thanks you for your help :)
Spreadsheet::WriteExcel
is in "maintenance-only mode" as per the description section on CPAN, replacement isExcel:Writer::XLSX
. – Gael