Simple does not do spanning... Now the Spreadsheet::ParseExcel data is still accessible in Spreadsheet::ParseExcel::Simple

use Spreadsheet::ParseExcel::Simple; use Data::Dumper; my $xls = Spreadsheet::ParseExcel::Simple->read('excel.xls'); foreach my $sheet ($xls->sheets) { die Dumper $sheet; #while ($sheet->has_data) { # my @data = $sheet->next_row; #} }

Take a look at the fields AlignH, AlignV and Merged. If Merged=1 you can have a value or no value.

So, in order to keep on using Spreadsheet::ParseExcel::Simple I added a small unmerge() function that removes the span's:

use Spreadsheet::ParseExcel::Simple; my $xls = Spreadsheet::ParseExcel::Simple->read('excel.xls'); foreach my $sheet ($xls->sheets) { #unmerge unmerge($sheet->{sheet}); while ($sheet->has_data) { my @data = $sheet->next_row; print join("\t", @data),"\n"; } } sub unmerge{ my($oWkS) =@_; 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->{MaxC +ol} ; $iC++) { $oWkC = $oWkS->{Cells}[$iR][$iC]; next unless $oWkC; if($oWkC->is_merged){ if($oWkC->Value){ print "COPY V=$oWkC->{Format}->{AlignV} H=$oWkC->{ +Format}->{AlignH}\n"; for my $i (1..$oWkC->{Format}->{AlignV}){ print "ADDV [$iR+$i][$iC] \n"; $oWkS->{Cells}[$iR+$i][$iC]->{_Value} = $oWkC- +>Value; $oWkS->{Cells}[$iR+$i][$iC]->{Merged}=0; } for my $i (1..$oWkC->{Format}->{AlignH}){ print "ADDH [$iR][$iC+$i] \n"; $oWkS->{Cells}[$iR][$iC+$i]->{_Value} = $oWkC- +>Value; $oWkS->{Cells}[$iR][$iC+$i]->{Merged}=0; } } } print "( $iR , $iC ) ==", $oWkC->Value, " ", $oWkC->{Merge +d},"\n"; } } }

This should copy/clone your spanned data... while still being able to use Simple...

in my case, my output was:

--------- SHEET:Sheet1 COPY V=2 H=0 ADDV [0+1][0] ADDV [0+2][0] ( 0 , 0 ) ==cat 1 ( 0 , 1 ) ==Fluffy ( 1 , 0 ) ==cat 0 ( 1 , 1 ) ==Vera ( 2 , 0 ) ==cat 0 ( 2 , 1 ) ==Manxie cat Fluffy cat Vera cat Manxie

edit: can you send me your xls example where the cell is at the second row, Libreoffice forces the data from the rightmost/topmost...

edit2: Ok, merged cells that already had a value, and my subroutine dies because the AlignH/AlignV are messed up. This will need some more tinkering before it works properly. (but need to sleep now)


In reply to Re: rowspan vals in Excel SS are not interpreted by ParseExcel::Simple by FreeBeerReekingMonk
in thread rowspan vals in Excel SS are not interpreted by ParseExcel::Simple by misterperl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.