[ic] XLS import failure - 255 character limit issue.

interchange-users@icdevgroup.org interchange-users@icdevgroup.org
Wed Sep 4 12:33:01 2002


Quoting Reid Sutherland (reid-ic@thirddimension.net):
> > What code are you using to verify that? We would need to compare
> > how it is done with the way IC does it.
> > 
> >        for( ; $iR <= $oWkS->{MaxRow}; $iR++) {
> > 	  my $row = $oWkS->{Cells}[$iR];
> > 	  @out = ();
> > 	  for($iC = $mincol; $iC <= $maxcol; $iC++) {
> > 	    if(! defined $row->[$iC]) {
> > 		push @out, "";
> > 		next;
> > 	    }
> > 	    push @out, $row->[$iC]->Value;
> > 	  }
> > 	  $sheets->{$sname} .= join "\t", @out;
> > 	  $sheets->{$sname} .= "\n";
> >        }
> > 
> > That is the loop that actually does the read. If there are embedded
> > newlines or TABs it might cause a problem...we could add some
> > translation stuff, I suppose. You might change this in import_fields:
> > 
> >     push @out, $row->[$iC]->Value;
> > 
> > to;
> > 
> >     my $v = $row->[$iC]->Value;
> >     $v =~ tr/\n\t/\r /;
> >     push @out, $v;
> > 
> > That will kill any tabs, of course, but will prevent import problems.
> > 
> 
> This would be fine since I don't care for TABs in HTML anyway.  But I 
> don't see any TABs in the particular Excel file.

Newlines? 

Did you try the change above in import_fields? From the code below,
I am not doing anything different than their test program, which I
probably cribbed from to build the routine.... 8-)

> 
> Here's the code I borrowed from ParseExcel example scripts to test my 
> Excel file.
> 
> --snip--
> my $oBook = $oExcel->Parse('test.xls');
> PrnBook($oBook);
> sub PrnBook($)
> {
>      my($oBook) = @_;
>      my($iR, $iC, $oWkS, $oWkC);
> 
>      print "=========================================\n";
>      print "FILE  :", $oBook->{File} , "\n";
>      print "COUNT :", $oBook->{SheetCount} , "\n";
>      print "AUTHOR:", $oBook->{Author} , "\n";
>      for(my $iSheet=0; $iSheet < $oBook->{SheetCount} ; $iSheet++) {
>          $oWkS = $oBook->{Worksheet}[$iSheet];
>          print "--------- SHEET:", $oWkS->{Name}, "\n";
>          for(my $iR = $oWkS->{MinRow} ;
>                  defined $oWkS->{MaxRow} && $iR <= $oWkS->{MaxRow} ; 
> $iR++) {
>              for(my $iC = $oWkS->{MinCol} ;
>                              defined $oWkS->{MaxCol} && $iC <= 
> $oWkS->{MaxCol} ; $iC++) {
>                  $oWkC = $oWkS->{Cells}[$iR][$iC];
>                  print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC);
>              }
>          }
>      }
> }
> --snip--
> 
> The variable naming is wicked and causes my eyes to hurt so it's hard 
> for me to understand what is happening here.
> 

The key call is to 

    print "( $iR , $iC ) =>", $oWkC->Value, "\n" if($oWkC);

which is the same as mine.

There is no reason that they should operate differently. Did you check
to see you don't have an old version of the library in INTERCHANGE_ROOT/lib?


-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

"Even if you're on the right track, you'll get run over if you just
sit there." -- Will Rogers