Parse Excel repeats columns

Parse Excel repeats columns

am 11.04.2006 05:46:25 von mfanderson

>Hi All,
I have picked up ParseExcel and started to work with it. I am having
a problem with code that essentially looks like this:

for ($iR = 0; ($oWkS->{MaxRows} && $iR <=$oWkS->{MaxRows}, $iR++){
for ($iC=0; ($oWkS->{MaxCols} && $iC <=$oWkS->{MaxRows}, $iC++){
$oWkC = $oWkS->{Cells}[$iR][$iC];
MyString .= " $oWkC->Value;
}
}

The problem is that sometimes the value in the cell for a given $iC is
repeated

MyString = "Cell 1 Cell 2 Cell 2 Cell 3"
instead of
MyString = "Cell 1 Cell 2 Cell 3"

It is an intermittant problem -- only one column, if that, on a worksheet
will be affected. And if I do more than one row, I see the same thing in
each row.

I think it may have something to do with the formatting of the EXCEL
spreadsheet. The first time it happened, I went through an formatted all
the columns with autofit to contents, and that seemed to take care of it.
This is the second time I am seeing it.

I wonder if you have any experience with this.

Thanks,
Mary

Re: Parse Excel repeats columns

am 11.04.2006 14:00:25 von sgoeldner

Mary Anderson wrote:

>
> >Hi All,
> I have picked up ParseExcel and started to work with it. I am having
> a problem with code that essentially looks like this:
>
> for ($iR = 0; ($oWkS->{MaxRows} && $iR <=$oWkS->{MaxRows}, $iR++){
> for ($iC=0; ($oWkS->{MaxCols} && $iC <=$oWkS->{MaxRows}, $iC++){
> $oWkC = $oWkS->{Cells}[$iR][$iC];
> MyString .= " $oWkC->Value;
> }
> }

Hmm, from an DBI users point of view, I'd try:

use DBI();

$dbh = DBI->connect('dbi:ODBC:driver=Microsoft Excel Driver (*.xls);dbq=test.xls;DriverID=790') or die $DBI::errstr;
$sth = $dbh->prepare('select * from [Table1$]');
$sth->execute;
$sth->dump_results;


Steffen