So I found Excel::Template
I thought you might head down this path and got to work trying to work up an example, but I have failed. The example I was shooting for was the one right on the cpan site: https://metacpan.org/pod/Excel::Template.
I worked it up two different ways and get the same error, so I'm hoping that my failure is diagnostic for the many contributors to the monastery whose experience in this is greater than mine. So far, I only have 2 failures.
At first, I thought my input file wasn't correct on the path, but I took the extra measure of stringifying the Path::Tiny values, with the attending certainty and liternalness of a string, and there is a file there with the xml example in it:
Then I read further on the cpan site that I can get the data from __DATA__ with FILE => \*DATA . I give that a whirl:
Same error:
Not a GLOB reference at /usr/local/share/perl/5.26.1/Spreadsheet/Write
+Excel/OLEwriter.pm line 250, <INFILE> line 0.000000.
(in cleanup) Not a GLOB reference at /usr/local/share/perl/5.26.1/
+Spreadsheet/WriteExcel/OLEwriter.pm line 418, <INFILE> line 0.000000.
I hope we can figure this out....
| [reply] [Watch: Dir/Any] [d/l] [select] |
Hello Aldebaran,
I finally got something neat that addresses 2 requirements : being able to access the XML and creating the XLS file for rendering to the user.
I'll share a piece of code below, which might answer your question about file/filename in the New() method.
I'm using 2 modules to achieve my objectives. Template & Excel::Template. I use the Template Toolkit to generate the required XML so that Excel::Template can produce the XLS. So my whole config generator engine benefits from TT and when I need an XLS file it's being treated separately.
use Template;
use Excel::Template;
sub xml_to_excel {
my ($template_conf, $file, $hashref) = @_; # template configuration
+from config file, filename based on request number, data for the tem
+plate processing
my $xml;
my $tt = Template->new({
RELATIVE => 1, # in my case I had to use relative path
+because of $template_conf->{file} based on CWD.
});
$tt->process( $template_conf->{file}, $hashref, \$xml ) || die $tt->e
+rror; # write the output to the $xml string
open my $xml_fh, "<", \$xml; # create a filehandle from the $xml str
+ing so that Excel::Template can read it.
my $ET = Excel::Template->new({
file => $xml_fh, # use the filehandle here
});
$ET->write_file($file);
return $xml || 0;
}
Hope this helps !
Luc | [reply] [Watch: Dir/Any] [d/l] |