in reply to Writing into an existing excelsheet

First off, n8g's points are very well taken. If I may, I would like to add a little. If you are using a fully Win32 environment, and actually have Excel as the environment for manipulating your spreadsheets, then Excel itself, perhaps with the aid of Visual Basic for Applications (the programming language built into Excel) would be an ideal solution.

If you are using a non-Windows platform to do the spreadsheet manipulation, then the combination of Spreadsheet::ParseExcel and Spreadsheet::WriteExcel are what you are looking for. ParseExcel will allow you to read the Excel file and pick and choose cells and retrieve the data. Once you have that, you can then use WriteExcel to create your new Excel file.

If you really do want to use Perl, and you are on a Windows platform, then I recommend the ActiveState Perl distribution. It includesWin32::OLE to allow you to programmatically work with Windows applications. If you use a barebones Windows Perl, you can get Win32::OLE from CPAN, if you don't want to install the ActiveState Perl. You can find details from various sites using the proper Win32::OLE Perl Excel search. What you'll have to do in this case is translate the API that is included in MS Office from the Visual Basic for Applications to the Perl Win32::OLE equivalent.

As an aside, for large spreadsheets, the Win32::OLE solution is faster than the Spreadsheet::WriteExcel solution, at least in my experience from a while back. The WriteExcel folks might have greatly improved performance, and I am not criticizing their excellent work, but it is a consideration.

  • Comment on Re: Writing into an existing excelsheet

Replies are listed 'Best First'.
Re^2: Writing into an existing excelsheet
by philc (Acolyte) on Sep 20, 2007 at 06:43 UTC
    Regarding Spreadsheet::ParseExcel, if you have a choice between this PM and doing it in Excel manually or with VB, go with the latter. Spreadsheet::ParseExcel is bit unweildly, slow and a memory hog in my experience. If using VB is not your thing and you're on Windows box, then definitely try Win32:OLE...a much cleaner interface than Spreadsheet::ParseExcel...just my humble two cents...I agree though that it may be best to do it via Excel/VB. pc