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

As I'm very comfortable with HTML::Template I've begun using Excel::Template. Everything is fine except Excel complains that the generated files are very corrupt. They seem to open fine after the warning from Excel, but it would be nice if I didn't have the warning at all.
Any ideas?

Replies are listed 'Best First'.
Re: Excel::Template corrupt output
by PodMaster (Abbot) on Aug 19, 2004 at 00:58 UTC
    Someone forgot to binmode (perl function). Yes, I am psychic

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      Excel::Template does binmode. (I am psychic, too.)

      ------
      We are the carpenters and bricklayers of the Information Age.

      Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

      I shouldn't have to say this, but any code, unless otherwise stated, is untested

Re: Excel::Template corrupt output
by dragonchild (Archbishop) on Aug 19, 2004 at 13:03 UTC
    I'm the author of Excel::Template. A few questions:
    • What version of E::T are you using? The latest version is 0.12
    • What version of Spreadsheet::WriteExcel?
    • What version of MS Excel?
    • What OS / Perl version are you using to generate the Excel file?
    • Are you using mod_perl or straight CGI? If mod_perl, are you using MP1 or MP2?
    • Can you give us a snippet of the Perl code that's generating the file? Try and make it the smallest amount of code that will reliably reproduce the error.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

    I shouldn't have to say this, but any code, unless otherwise stated, is untested

      Excel::Template 0.12
      Spreadsheet::WriteExcel 2.03
      MS Excel 2003
      Linux w/2.4 kernel, Perl 5.6.2
      Command line
      #!/usr/bin/perl -w use strict; use Excel::Template; my $excel_template = Excel::Template->new(filename => 'test_template.x +ml'); $excel_template->write_file('test.xls');

      Here's the template:
      <workbook> <worksheet name="Test"> <cell text="A single cell"/> </worksheet> </workbook>
        I ran your code with the following setup and it worked just fine without any errors. You sure you're using a binary transfer mode when ftp'ing the file?
        • RH9 (2.4 kernel), Perl 5.8.0 (vendor build)
        • S::WE 2.04, E::T 0.12
        • MS Excel 2002 (I don't have access to Office2k3)

        ------
        We are the carpenters and bricklayers of the Information Age.

        Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

        I shouldn't have to say this, but any code, unless otherwise stated, is untested