473,326 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Excel Worksheet to CSV

hi,

Refering to thread: Open and create new Excel file with Perl and win32::OLE

Can you please give a code to save an excel sheet with a different extension?

my $Excel = Win32::OLE-> new ('Excel.Application', 'Quit') or die ("Can't create object: ", Win32::OLE->LastError());
$Excel->{DisplayAlerts}=0;

my $excelfile = 'C:\PERL\bin\INBOUND.xls';

my $Book = $Excel->Workbooks->Open($excelfile)or die ("Can't open Workbook: ", Win32::OLE->LastError());


my $Sheet = $Book->Worksheets("ELEMENT");

now i need to save the excel sheet ,ELEMENT to ELEMENT.csv as a different file into a different folder.how do i do this?
Jun 7 '07 #1
5 5069
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?
Jun 7 '07 #2
miller
1,089 Expert 1GB
Greetings,

No sample code will be provided by me. However, this task is easily accomplished. Simply use the following two modules. The first one parses a Excel spreadsheet. The second one gives you functions for creating a CSV file.

cpan Spreadsheet::ParseExcel
cpan Text::CSV

There are examples provide in the documentation for both of these modules.

Good Luck,
- Miller
Jun 7 '07 #3
I need to know if it can be accomplished using Win32::OLE
Jun 8 '07 #4
miller
1,089 Expert 1GB
It might be possible to solely use Win32::OLE, but I have no experience with that module so I can't say for sure. I'm guessing that you're hoping for the equivalent of a Save-As CSV, but I honestly don't think that you're going to find that.

At the very least, if you can access the data of a worksheet via this module, then you could pair it with the Text::CSV module that I refered to previous. Or if you're rousing for a bruising, then you could just do it all manually. But I would definitely advise against that.

- Miller
Jun 8 '07 #5
bbobbo
1
hi,

Refering to thread: Open and create new Excel file with Perl and win32::OLE

Can you please give a code to save an excel sheet with a different extension?

my $Excel = Win32::OLE-> new ('Excel.Application', 'Quit') or die ("Can't create object: ", Win32::OLE->LastError());
$Excel->{DisplayAlerts}=0;

my $excelfile = 'C:\PERL\bin\INBOUND.xls';

my $Book = $Excel->Workbooks->Open($excelfile)or die ("Can't open Workbook: ", Win32::OLE->LastError());


my $Sheet = $Book->Worksheets("ELEMENT");

now i need to save the excel sheet ,ELEMENT to ELEMENT.csv as a different file into a different folder.how do i do this?
this thread is long dormant, but for anyone stumbling across it, here's the answer:

$Sheet->SaveAs("NEWFILENAME.CSV", xlCSV);
Sep 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Allison Bailey | last post by:
Hi Folks, I'm a brand new Python programmer, so please point me in the right direction if this is not the best forum for this question.... I would like to open an existing MS Excel spreadsheet...
1
by: c duden | last post by:
Excel won't allow documents to be linked to a worksheet in office 2000 when using C# to create an add-in. The following code snippets are what was used in the attempts (there are more...
1
by: mail2atulmehta | last post by:
Hi, I do not know if this is right place for this, but i need some help. I have a text file, whose values are seprated by a delimiter. I want to open this file in excel, ( not import it) . I have...
0
by: dgoel | last post by:
Hi, I Have a text file & I want to open it in excel sheet ( withou importing). I have written code for it, but it is not opening exce sheet. It opens the text file, but does not create a excel...
1
by: javzxp | last post by:
Hi I'd like to use C# to open an existing Excel workbook and save each worksheet it contains into a new Excel file. The name of each new Excel file should be the name of the worksheet copied...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
8
by: Sam | last post by:
Hi All, I posted this message few days ago. No one has answered so far. I just would like to know if it is possible to do or not. Even if you can not tell me how to do this, maybe you know which...
1
by: Randall Arnold | last post by:
I'm converting a vbscript program to vb.net. Witht he exception of .net idiosyncrasies, most of it is working well with the same code. My only problem is that some properties and methods are...
6
by: gumbystation | last post by:
I am looking to take data from an excel spreadsheet into a csharp application to manipulate the data in various ways. Currently, I am using VS2005 (self-taught C#) and Excel 2000. I have...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.