|
From: Anand on 6 May 2008 17:04 On May 5, 4:58 pm, Jim Gibson <jimsgib...(a)gmail.com> wrote: > In article > <fea47429-8010-4353-bbd2-dc4c825bf...(a)p39g2000prm.googlegroups.com>, > > Anand <anand.acha...(a)gmail.com> wrote: > > I am trying to read an excel file usign the writeexcel. Following is > > the code-snippet: > > my $workbook = Spreadsheet::WriteExcel->new('Temp.xls'); > > > print "Cannot create Temp.xls: $!\n" if (not defined $workbook); > > > foreach $worksheet ($workbook->sheets()) { > > print "Worksheet Name is: ".$worksheet->get_name()."\n"; > > } > > > The file Temp.xls is already existing in the directory. I want to > > further modify the worksheets. However, the sheets() method itself is > > not working. > > What might be the reason? I'm using perl 5.8 > > Have you read the documentation for Spreadsheet::WriteExcel? > > From 'perldoc Spreadsheet::WriteExcel': > > "This module cannot be used to write to an existing Excel file." > > To modify an existing spreadsheet file, your choice is to create a new, > empty spreadsheet with Spreadsheet::WriteExcel, read the existing > spreadsheet with Spreadsheet::ParseExcel, and copy the information in > the existing spreadsheet to the new one, or search CPAN for a module > that can update an existing spreadsheet. I believe there used to be > one, but I have never used it and cannot find it. > > -- > Jim Gibson > > Posted Via Usenet.com Premium Usenet Newsgroup Services > ---------------------------------------------------------- > http://www.usenet.com Thanks Jim. I could successfully use WriteExcel to create a workbook. I created three worksheets. However, I'm having issues when I switch between sheets. If I switch between the sheets, the output file vanishes and gets replaced by an empty file. $oSheet1 = $oWorkbook->sheets(0); ..... Write some data on Sheet(0)..... $oSheet2 = $oWorkbook->sheets(1); ..... Write some data on sheet(1); After theses statements, my output file is of zero size with no data in it. If I use only one sheet of the two, it works fine but updates only one sheet. thanks, Anand.
From: Jim Gibson on 5 May 2008 19:58 In article <fea47429-8010-4353-bbd2-dc4c825bf039(a)p39g2000prm.googlegroups.com>, Anand <anand.acharya(a)gmail.com> wrote: > I am trying to read an excel file usign the writeexcel. Following is > the code-snippet: > my $workbook = Spreadsheet::WriteExcel->new('Temp.xls'); > > print "Cannot create Temp.xls: $!\n" if (not defined $workbook); > > foreach $worksheet ($workbook->sheets()) { > print "Worksheet Name is: ".$worksheet->get_name()."\n"; > } > > The file Temp.xls is already existing in the directory. I want to > further modify the worksheets. However, the sheets() method itself is > not working. > What might be the reason? I'm using perl 5.8 Have you read the documentation for Spreadsheet::WriteExcel? From 'perldoc Spreadsheet::WriteExcel': "This module cannot be used to write to an existing Excel file." To modify an existing spreadsheet file, your choice is to create a new, empty spreadsheet with Spreadsheet::WriteExcel, read the existing spreadsheet with Spreadsheet::ParseExcel, and copy the information in the existing spreadsheet to the new one, or search CPAN for a module that can update an existing spreadsheet. I believe there used to be one, but I have never used it and cannot find it. -- Jim Gibson Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- http://www.usenet.com
From: Ben Bullock on 5 May 2008 20:10 On Mon, 05 May 2008 16:58:48 -0700, Jim Gibson wrote: > To modify an existing spreadsheet file, your choice is to create a new, > empty spreadsheet with Spreadsheet::WriteExcel, read the existing > spreadsheet with Spreadsheet::ParseExcel, and copy the information in > the existing spreadsheet to the new one, or search CPAN for a module > that can update an existing spreadsheet. I believe there used to be one, > but I have never used it and cannot find it. The obvious solution is to use Win32::OLE to do everything. I'd only use the Perl Excel reading / writing modules if I had to do something with an Excel spreadsheet on Unix.
|
Pages: 1 Prev: RXParse 1.2 Next: WriteExcel->sheets() fails to get the worksheets |