Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Excel how to open existing worksheet

by jandrew (Chaplain)
on Jan 27, 2015 at 22:27 UTC ( #1114677=note: print w/replies, xml ) Need Help??


in reply to Excel how to open existing worksheet

Win32::OLE but it's a bad idea. You will also need some strongish VBscript-ing skills to go with it since Many Win32::OLE options are not documented and knowing the VBscript equivalent will allow you to find functions that you need. The actual process is to open the Microsoft Excel application, read the file into Excel with your script (Don't manually try and interact with Excel when the script has it open), make your changes, save the file, and then close Excel again.

From a data-safe standpoint there is very little keeping you from overwriting something accidentally using this process. Additionally these scripts are not very portable since they rely heavily on the Excel settings embedded in each computers Excel installation.

The alternative is to export your perl data with a .csv file using the excellent Text::CSV and either import the data to the existing Excel manually (Data/From Text/FileName.csv) or do the same with a Macro or PowerShell.

  • Comment on Re: Excel how to open existing worksheet

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2023-02-06 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (33 votes). Check out past polls.

    Notices?