I suppose this (parsing the entire file, making changes, then writing it back) is the way to go, since modules like DBD::Excel seem to do it.

I had to face a similar problem some time ago. It was probably easier because I had to edit a set of fixed templates to generate weekly and monthly reports in Excel format for the management.

Lacking fancy formatting, CSV was not enough <SAD_BUT_TRUE>even though the information was just the same of course</SAD_BUT_TRUE>.

In the end I decided to parse the templates once, I wrote a set of long-but-easy functions, one for each template, then all I needed was just some additional code to write the actual data into the chosen template.

If your templates are not complex, you may decide to copy, not parse them, converting by hand into Perl code or whatever suits your needs.

The additional code I had for each template was a simple (yet longish) function taking a hash as a parameter with all the information I needed to "plug" in the template.

Obviously this is practical if you always have a fixed set of templates to edit, not sheets that differ every time.

-- TMTOWTDI


In reply to Re: Excel from Perl by trantor
in thread Excel from Perl by ws_stefan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.