CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Unable to read a xls file completely


New User

Jan 5, 2017, 2:36 AM

Post #1 of 2 (2047 views)
Unable to read a xls file completely Can't Post

Dear Friends,

I have an .xls file . I want to read each and every cells containing the data. By this program I can only read all rows but only first column's data . Can any body help me in reading all row and columns data. I will be highly oblige to you. Thanks

#!/usr/bin/perl -w 

use strict;
use Spreadsheet::ParseExcel;

my $parser = Spreadsheet::ParseExcel->new();
my $workbook = $parser->parse('d:/xyz.xls');

if ( !defined $workbook ) {
die $parser->error(), ".\n";
for my $worksheet ( $workbook->worksheets() ) {

my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();

foreach my $row ( $row_min .. $row_max ) {
foreach my $col ( $col_min .. $col_max ) {

my $cell = $worksheet->get_cell( $row, $col );
next unless $cell;

print "Row, Col = ($row, $col)\n";
print "Value = ", $cell->value(), "\n";
print "Unformatted = ", $cell->unformatted(), "\n";
print "\n";

(This post was edited by FishMonger on Jan 5, 2017, 8:05 AM)

Veteran / Moderator

Jan 5, 2017, 8:27 AM

Post #2 of 2 (2042 views)
Re: [suvendra] Unable to read a xls file completely [In reply to] Can't Post

Your script works correctly for me.

Can you post your sample xls file and the output your script gives when parsing that file so that I can see if I can duplicate your problem.


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives