I wanted to build an awesome place for people to discuss module specific issues, but I don't have any more time for this, and there are much better places to discuss Perl-related issues. I'd recommend asking your question on Stack Overflow or on Perl Monks.
If you are looking for a Perl tutorial or Perl-related news, I hope these links will serve you well.
Posted on 2010-06-09 01:31:52.021375-07 by bene
How to detect if a table cell is empty?
I've browsed all entries of this forum but couldn't any hint to solve my problem:
My OO-Writer document has a two-column table and
I want to detect if the first cell of the second column is empty and I use the following code:
my $CellVal2 = $doc->cellValue($Tablename,0,1) ; if ( defined $CellVal2 && "" ne $CellVal2 ) { print "Row is NOT empty\n" if ($Verbose); } else { print "Row is empty\n" if ($Verbose); }

This works as long as the cell (0,1) only contains normal text.
As soon as the cell contains an enumeration like this
1 Item1
2 Item2
or a more complicated, formatted sturcture, the code doesn't work any more.

So, my question is:
How can I detect if a table cell is empty?

Best regards,
Siegfried Kurz
Direct Responses: 12763 | Write a response
Posted on 2010-06-10 07:20:24.053352-07 by jmgdoc in response to 12756
Re: How to detect if a table cell is empty?
First you can rerieve the cell object using getCell(), then count the elements inside the cell using the element-based children() method (this method is provided by XML::Twig, so it's not documented with OpenOffice::OODoc). Example:
my $cell = $doc->getCell($Tablename, 0, 1); my @elements = $cell->children;

After the code sequence above, @elements is the list (possibly empty) of the elements inside the cell.
Direct Responses: 12765 | Write a response
Posted on 2010-06-11 04:56:44.482492-07 by bene in response to 12763
Re: How to detect if a table cell is empty?
Thank You,
this workes fine!

Best regards,
Siegfried
Direct Responses: Write a response