Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: Modifying an Excel doc (UNIX)

by dpmott (Scribe)
on Dec 05, 2003 at 04:37 UTC ( [id://312425]=note: print w/replies, xml ) Need Help??


in reply to Re: Modifying an Excel doc (UNIX)
in thread Modifying an Excel doc (UNIX)

We have things in the workbook like those popup controls, and VBA macros that pull data out of the other worksheet to populate those controls.

Between the controls and the VBA macros, and also the desire to lay out the look+feel of the first spreadsheet (it's basically an end-user form), it seems like a path fraught with perils and hardship to generate the whole thing with Excel::Template or Spreadsheet::WriteExcel.

Unless I'm missing something? I didn't see a way that the two modules natively worked together? i.e. didn't see:
my $oBook = new Spreadsheet::ParseExcel->new()->Parse('file.xml'); my $template = Excel::Template->new($oBook); # or my $xml = Spreadsheet::ParseExcel->new()->Parse('file.xml')->toXML( +); my $template = Excel::Template->new($xml);
Actually, I didn't even see a way to directly supply a string for Excel::Template to parse. Would I have to make one of those nifty string-backed in-memory files to make that work?

Nor did I see that Excel::Template would read+parse an Excel file and give you the XML that you could then twiddle into a desired template. If I missed something obvious there, let me know.

I appreciate your offer to add features... off the top of my head (and unless I missed them), I'd suggest a parse_string() method, and an interface to supply a workbook from Spreadsheet::ParseExcel (which would generate an XML representation of that workbook). That last one sounds painful, though... might be better to have Spreadsheet::ParseExcel attempt to render the XML for you?

-Dave

Replies are listed 'Best First'.
Re3: Modifying an Excel doc (UNIX)
by dragonchild (Archbishop) on Dec 05, 2003 at 13:43 UTC
    First off, neither Excel::Template nor Spreadsheet::WriteExcel will parse, just like Spreadsheet::ParseExcel will not write. And, because they have very different purposes, they were not built to work together. (Now, it doesn't mean that they cannot. There is a module on CPAN that will read and write to the same spreadsheet ... kinda - it reads and then overwrites.)

    Now, Excel::Template, like its name suggests, builds XLS files from a template in a file and a data structure in memory. You use the template for the look'n'feel and the data structure for the data, like HTML::Template. (It was built to be a helper to HTML::Template.)

    If I understand the real problem you're attempting to solve, you have a workbook that you need to provide to some end users. That workbook has a bunch of data and the like that needs to go into a given layout. Your workbook will always have N columns, but the specific data in B5 (or whatever) will change. (Maybe, one day it's "Chicago" and the next day it's "New York".)

    This is the perfect place for a template. It requires rethinking your approach. But, it's doable.

    Now ... taking the XML from Spreadsheet::ParseExcel and creating a template ... that would be problematic. Here's the issue - Excel::Template is actually misnamed - it should really be called Excel::Layout. Templating is only the smaller part of what it does - it really does the layout for an XLS.

    The long and short of this is that I would have no way of determining that the first 10 rows belong to the CITIES loop and the second 10 rows belong to the STATES loop. The layout is something provided by a human, as is the data structure. The module should stick to what it does and get good at that.

    A parse-string method would certainly be helpful. I'll put that in the next release. Thanks!

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

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

      I want to modify an excel file that contains macros and activex objects but parsing and then saving removes these things ....

      @dragonchild gave suggestion for using Excel::Template but as much i could grasp first u need to create .xml and create whole sheet using the perl code

      Isn't there some module like WIN32::OLE for UNIX

      Please suggest some way i don't want create the whole excel again.

      Any help would be appreciated

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://312425]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (2)
As of 2024-04-24 23:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found