perl_new_b:

The file and data format(s) in Excel are complex. So you're going to have to (a) use Win32::OLE or an equivalent to let your program tell Excel (or OpenOffice or other application that can read/write Excel files) to do the work, (b) parse the file, edit the data, and write the new/updated file, or (c) write the data in a simpler format, edit the data, write the file in an Excel-compatible form.

I've had the same problem with large spreadsheets myself, and used the trick in Spreadsheet::ParseExcel under the heading "Reducing the memory usage of Spreadsheet::ParseExcel" by extracting just the data I needed and discarding the rest, and it worked well enough. Recently a client upgraded Excel and now uses .xlsx files, so I've had to parse some of the data out myself (spelunking through the XML). (Not as simple as it should be, by the way.)

Fortunately, I've always had control of the formatting, and never had to deal with embedded objects (such as charts) so I haven't been bitten by the "just add a few lines to an existing workbook" problem--instead I just sucked out the data and generated a brand new workbook.

Hmmm ... I just thought of another route: (d) store your data in a database (e.g. SQLite) or flat file, and write some VBA code to update the data on demand. So the user could simply open the workbook and run the "update workbook" function for you. It's non-perly and would require a bit of work to get set up. But then the users could pull updates whenever they wished, and you would need only keep the database up-to-date. In fact, I like this one enough that I may do it for the client I normally do spreadsheet work for.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re^11: How to use win32::OLE with multiple versions of Microsoft Office? by roboticus
in thread How to use win32::OLE with multiple versions of Microsoft Office? by frida

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.