Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Excel 2007 Support

by lecanardroti (Initiate)
on Jun 24, 2009 at 20:15 UTC ( [id://774510] : note . print w/replies, xml ) Need Help??

in reply to Writing Excel spreadsheets with Perl

There is one advantage of Win32::OLE that has not been mentioned. It works with Excel 2007. This works because Win32::OLE makes use of the COM objects installed on the workstation itself. While this limits portability beyond Windows (and perhaps even on Windows for certain features), it has the advantage of not requiring an update to the module. As far as I can tell, none of the Spreadsheet::<module> modules work with Excel 2007. Perhaps this can be addressed in a future build, but currently it is necessary to use Win32::OLE if you have to deal with the newer version. The file format is different for Excel 2007 than for Excel 2003 and earlier. Microsoft even designated a new extension for it, *.xlsx (2007) instead of *.xls (2003 and earlier).

Replies are listed 'Best First'.
Re: Excel 2007 Support
by afoken (Chancellor) on Jun 24, 2009 at 21:45 UTC

    Excel 2007 uses ZIP compressed XML, labelled Office Open XML. It roughly looks like the open standard ODF used in free software, but it seems Microsoft intentionally made its format incompatible with the ODF format.

    As both standards are based on XML, and both are more or less documented, you "simply" generate some XML, ZIP it, and rename it to *.xlsx. (Perhaps you have to sacrifice some chickens, burn some candles, and draw some blood pentagrams on that way. But you should be used to such procedures when you deal with XML and/or Microsoft software, so nothing special here. ;-)) The OpenOffice::OODoc package should at least be able to read and write the ODF format without hurting animals.


    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
Re: Excel 2007 Support
by Anonymous Monk on Sep 29, 2009 at 12:02 UTC
    Hi, I am trying to find a perl module which can work with MS excel 2007. Forom your explaination and based on my study from CPAN i understnd that no perl module can be used to write in MS excel 2007. Is is thisbeacuse non -avaolability of proper perl modules.

      As the grandparent post said, you can still use Win32::OLE. Also, maybe XLSX can write XLSX files.

        Spreadsheet::XLSX - this is the Perl extension for reading MS Excel 2007 files but not to write i believe. Win32::OLE : i believe it is only on windows not on UNIX machines. Is there anyone tried to install XLSX module and tried? Please let me know ASAP? Many thanks.
Re: Excel 2007 Support
by Anonymous Monk on Dec 09, 2010 at 13:38 UTC

    Hi, the above information was very use full to me.I did a project where i need to generate a excel file. I used spreadsheet::WriteExcel, I am able to see complete data in the output file in Excel2002 version. Where as the client had MSExcel2007 for him, he was getting an error 'data lost'. And he is not able to see the complete data. After reading this I found that I should use Win32::OLE. I will go for this. I had a bad experience with the Microsoft products. No compatibility between different versions.

      Hi Monks am not able to update all data from a array in to excel.... its getting updated only last elements from the array.. Any one idea..on this bug... Thanks Manohar kusa

        You replied to a post from 8 years ago, with a vague description of a different problem, showing no code. In order to get an help with your problem you need to post code which reproduce the issue you have. How do I post a question effectively? explains the process.