473,412 Members | 2,050 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,412 software developers and data experts.

creating an excel file for writing

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Win32::OLE qw(in with);
  4. use Win32::OLE::Const 'Microsoft Excel';
  5. my $Excel = Win32::OLE->new('Excel.Application', 'Quit');  
  6. my $Book = $Excel->Workbooks->Open("c:/file_excel.xls"); 
  7. my $Sheet = $Book;
I am new to perl.I am trying to create an excel file with the above code, but i am not getting it.Can you help in creating an excel file.
Dec 19 '07 #1
1 1620
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use Win32::OLE;
  4. use Win32::OLE::Const 'Microsoft Excel';
  5. use Win32::OLE::Variant qw(:DEFAULT nothing);
  6. $Win32::OLE::Warn = 3;
  7. my $excelObj = Win32::OLE->new('Excel.Application', 'Quit');
  8. $excelObj->{'DisplayAlerts'} = 0;
  9. $excelObj->{'AskToUpdateLinks'} = 0;
  10. $excelObj->{'Visible'} = 0;
  11. my $bookObj;
  12. my $sheetObj;
  13. eval
  14. {
  15.     $bookObj = my $Book = $excelObj->Workbooks->Add;
  16. };
  17. if($@)
  18. {
  19.     die "A problem was encountered when creating file.\n";
  20. }
  21. $sheetObj = $bookObj->Worksheets(1);
  22. for my $row (1..10)
  23. {
  24.     for my $col (1..10)
  25.     {
  26.         $sheetObj->Cells($row,$col)->{'Value'} = $row * $col;
  27.     }
  28. }
  29. $bookObj->SaveAs('d:\mohan.xls');
  30. $bookObj->Close();
  31. $excelObj->Quit();
Dec 19 '07 #2

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

Similar topics

6
by: Jeremy Langworthy | last post by:
Hi I am trying to create a MS Excel format CSV but I can't figure out how to get the line feed/carriage return/new record working properly. I am nding each line/record with these characters:...
6
by: Kerri McDonald | last post by:
We have an application where the user fills out many screens and when they are done, we are supposed to display the text they entered in a word or excel format. That is fairly easily accomplished...
3
by: Utada P.W. SIU | last post by:
Dear All, I have writing a ASP that export an Excel file by using response.contentType = "application/vnd.ms-excel" I can export an Excel However, the grey color gridline is missed, how can I...
9
by: Paul | last post by:
Hi all Arggghhh........... The problem.....I want the user to be able to create an excel document and name particular cells in the document where they want the data to be placed and then save...
4
by: Hans [DiaGraphIT] | last post by:
Hi! I want to export a dataset to an excel file. I found following code on the net... ( http://www.codeproject.com/csharp/Export.asp ) Excel.ApplicationClass excel = new ApplicationClass();...
0
by: volume | last post by:
Hi all, In an effort to try to impress the boss, I would like to log accounting information to an Excel spreadsheet using C# and .NET. This would be a mockup only, not a real solution - yet! We...
9
by: hari krishna | last post by:
hi, I want to send the data from dataset information to Excel through ASP.Net. there will be no XL installed on web server. web server is win 2000 server machine. I am using visual basic code in...
2
by: asad | last post by:
hello, how ru all pls tell me how can i create DAL and how can i use it in my ASP.NET pages thanks
3
by: RJN | last post by:
Hi I've a template excel file which has all the calculations defined. There are certain input values to be entered which gives a lot of output to the user. I don't want to expose the excel sheet...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.