Re: Perl and XLS operation
"Tod Harter" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.xml |
|---|---|
| Message-ID | <[email protected]> |
I think supporting the WriteExcel module is a bit outside the remit for this mailing list. This list is only for Perl XML questions and I don't know anything much about the WriteExcel module. You will have better luck trying one of the other lists. Sorry. On Mon, Nov 24, 2008 at 9:59 AM, <[email protected]> wrote: > Hi All, > > I want to write a perl script which let me override/edit the existing or > created XLS. But I am unable to do that. I am not sure, do I have to use > few more CPAN module or what your help will be > appreciated. Please find the snippet of the code which I have for the > creation of the XL sheet for your kind reference as below. > > #!/usr/bin/perl -w > > > ###################################################################### > # > # Example of how to use the Spreadsheet::WriteExcel module to > create > # an Excel binary file. > # > > use strict; > use Spreadsheet::WriteExcel; > > # Create a new Excel workbook called perl.xls > my $workbook = Spreadsheet::WriteExcel->new("perl.xls"); > > # Add some worksheets > my $sheet1 = $workbook->add_worksheet();my $sheet1 = $workbook > ->add_worksheet(); > *# error comes when I change above line as below, while > editing * > * # my $sheet1 = $workbook->add_worksheet("Derive");* > > my $sheet2 = $workbook->add_worksheet("Example"); > > # Add a Format > my $format = $workbook->add_format(); > $format->set_bold(); > $format->set_size(15); > $format->set_color('blue'); > $format->set_align('center'); > > # Set the width of the first column in Sheet3 > $sheet2->set_column(0, 0, 30); > > # Set Sheet2 as the active worksheet > $sheet2->activate(); > > # The general syntax is write($row, $col, $token, $format) > > # Write some formatted text > $sheet2->write(0, 0, "Hello Excel!", $format); > > # Write some unformatted text > $sheet2->write(2, 0, "One"); > $sheet2->write(3, 0, "Two"); > > # Write some unformatted numbers > $sheet2->write(4, 0, 3); > $sheet2->write(5, 0, 4.00001); > > # Write a number formatted as a date > my $date = $workbook->add_format(); > $date->set_num_format('mmmm d yyyy h:mm AM/PM'); > $sheet2->write(7, 0, 36050.1875, $date); > > Here, at first time I am able to open a XLS and write to that, but if I > want to do some changes next time, then it is not allowing me to do that. > and getting the follwing error. > > C:\Documents and Settings\x0069183\Desktop\Mustafa>perl hello.pl > *Can't open perl.xls. It may be in use or protected at hello.pl line 13 > (in cleanup) Can't use string ("") as a symbol ref while "strict > refs" in use at C:/Perl/site/lib/Spreadsheet/WriteExcel/Workbook.pm line > 295. > Can't call method "add_worksheet" on an undefined value at hello.pl line > 16.* > > Here I have used the module spreadsheat::WriteExcel. > > Please let me know how to overcome this. > > > > -- > Regards, > Mustafa > > > * Please do not print this email unless it is absolutely necessary. * > > The information contained in this electronic message and any attachments to > this message are intended for the exclusive use of the addressee(s) and may > contain proprietary, confidential or privileged information. If you are not > the intended recipient, you should not disseminate, distribute or copy this > e-mail. Please notify the sender immediately and destroy all copies of this > message and any attachments. > > WARNING: Computer viruses can be transmitted via email. The recipient > should check this email and any attachments for the presence of viruses. The > company accepts no liability for any damage caused by any virus transmitted > by this email. > > www.wipro.com > > _______________________________________________ > Perl-XML mailing list > [email protected] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > > -- The Wise adapts himself to the world. The Fool adapts the world to himself. Therefore, all progress depends on the Fool. _______________________________________________ Perl-XML mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs