#!/usr/bin/perl -w use strict; use CGI qw( -oldstyle_urls :standard ); use CGI::Carp qw ( fatalsToBrowser ); use Spreadsheet::ParseExcel; print header(); my $header_account; my $header_name; my $got_number; my $got_name; my $f_to_parse="accounts.xls"; my $workbook = Spreadsheet::ParseExcel::Workbook->Parse($f_to_parse)or die "Unable to open $f_to_parse\n"; foreach my $page (@{$workbook->{Worksheet}}) { if ((defined $page->{MinCol}) && (defined $page->{MaxCol})) { foreach my $col ($page->{MinCol} .. $page->{MaxCol}) { if ($page->{Cells}[0][$col]->{Val} eq 'Account Numbers') { $header_account = $col; } if ($page->{Cells}[0][$col]->{Val} eq 'Account Names') { $header_name = $col; } } } if ((defined $page->{MinRow}) && (defined $page->{MaxRow})) { foreach my $row ($page->{MinRow}+1 .. $page->{MaxRow}) { $got_number = $page->{Cells}[$row][$header_account]->{Val}; $got_name = $page->{Cells}[$row][$header_name]->{Val}; } } } # here I will insert the values from the xls file into the database if they are true. print "got_number=$got_number\n"; print "got_name=$got_name\n";