poojapo3 has asked for the wisdom of the Perl Monks concerning the following question:

hi, I wish to know if there is a way in perl using Win32::OLE to export a specific Excel Worksheet (not the entire workbook) from a workbook as a .csv file? Can you give me the sample code for the same?

Replies are listed 'Best First'.
Re: export excelsheet as .csv
by Tux (Canon) on Jun 07, 2007 at 11:16 UTC

    Why are you bound to Win32::OLE?

    Spreadsheet::ParseExcel offers all functionality you need to extract (parts of) a xls spreadsheet.

    My Spreadsheet::Read comes with the xlscat utility that, in combination with Text::CSV_XS can export that selection to CSV format.


    Enjoy, Have FUN! H.Merijn
Re: export excelsheet as .csv
by Corion (Patriarch) on Jun 07, 2007 at 12:27 UTC

    If Spreadsheet::ParseExcel (or XLSPerl for a complete, premade solution) is not your thing, maybe ExcelPerl by strat shows you the techniques how to use Win32::OLE to do what you want.

    A technique I've found very convenient is to use the Excel Macro Recorder to create Visual Basic code for what I want to do and then to translate that VB code to Perl.