Hi Tony,
Here is the code.
#!/usr/bin/perl
use IO::Uncompress::Unzip qw(unzip $UnzipError);
use Spreadsheet::ParseExcel::Simple;
use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Utility;
$excel_directory = 'C:\Test';
opendir(EXCELDIR, $excel_directory) || die ("no excel directory");
@excelfiles = readdir(EXCELDIR);
foreach $exxfilename (@excelfiles){
$x = 0;
$y = 0;
$c = 0;
if ($exxfilename =~ /^\.+.*/) { next; }
$xls = Spreadsheet::ParseExcel::Simple->read($exxfilename);
$str = substr($exxfilename,0,5);
$filename = $str.'GeneName.xls';
$workbook = Spreadsheet::WriteExcel->new($filename);
$worksheet = $workbook->add_worksheet();
foreach $sheet ($xls -> sheets()) ### This command is not working. The
sheets () is not working.
{
while ($sheet->has_data) {
@data = $sheet->next_row;
@grepNames = grep(/Gene Name/, @data);
if ($grepNames == 1){
$c = $c + 1;
}
if ($c == 1){
$gene_name = $data[4];
$worksheet->write($y++, $x, $gene_name);
}
}
}
}
closedir(EXCELDIR);
Kindly let me know other alternatives to read the xls file and parse a
definite column with no definite starting row and ending row in Excel sheet.
Thanks.
Regards,
Ayush Raman
On Fri, Jun 19, 2009 at 6:55 AM, tony@tmtm.com via RT <
bug-Spreadsheet-ParseExcel-Simple@rt.cpan.org> wrote:
Show quoted text> <URL:
http://rt.cpan.org/Ticket/Display.html?id=47136 >
>
> On Fri, Jun 19, 2009 at 8:53 AM, Ayush Raman via
> RT<bug-Spreadsheet-ParseExcel-Simple@rt.cpan.org> wrote:
> > I have been trying to use Spreadsheet-ParseExcel-Simple module for my
> script
> > but it is giving me the following error.
> > Can't call method "sheets" on an undefined value
>
> Hi Ayush,
>
> Unfortunately I can't diagnose much from that. Does this happen with
> every spreadsheet? Can you send through the code you're using?
>
> Thanks,
>
> Tony
>
>
--
Regards,
Ayush Raman