monir has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I know there is a perl module for writing to excel files. I need some features of Excel like addning comments to cells. Does anyone know if these features are supported in ParseExcel? or Win32:OLE Thanks, -Monir

Replies are listed 'Best First'.
Re: Excel cell commenting?
by Nkuvu (Priest) on Aug 10, 2004 at 00:59 UTC
    I was able to do this using Win32::OLE with the following code:
    $Worksheet->Range("$column$row")->AddComment("Foo!");
    where $Worksheet, $column, and $row are properly defined before the statement, of course.
      Hi, Where can I find the docuemntation on what methods are available for Excel? I tried AddComment and it worked. But I need molre functionalities like adding fill color, deleting comments etc. I tried: $Sheet->Range("c8:c8")->SetFill("Red"); and it failed. I read the Win32::OLE documentaiton but that does not give Excel specific methodd details. Regards, -Monir
Re: Excel cell commenting?
by hawtin (Prior) on Aug 10, 2004 at 08:12 UTC

    Spreadsheet::WriteExcel indeed does have a write_comment() method. Unfortunately version 0.42 (where write_comment() works) uses an old Excel version and cannot support cells with more than (I think) 256 characters. The newer version 2.01 uses Excel97 format and allows more text in cells but the write_comment() method is inactive.

    Spreadsheet::WriteExcel is a great module but some of these quirks still remain. I have never tried Win32:OLE

Re: Excel cell commenting?
by reneeb (Chaplain) on Aug 10, 2004 at 06:23 UTC
Re: Excel cell commenting?
by dfaure (Chaplain) on Aug 09, 2004 at 23:38 UTC

    All current Spreadsheet::ParseExcel features are listed at CPAN, just follow the link (I don't think comments are handled).

    Super Search will also help you finding here some hints and samples provided by others.

    ____
    HTH, Dominique
    My two favorites:
    If the only tool you have is a hammer, you will see every problem as a nail. --Abraham Maslow
    Bien faire, et le faire savoir...

Re: Excel cell commenting?
by EverLast (Scribe) on Aug 10, 2004 at 11:41 UTC
    I can recommend loading your file through Win32::OLE and touching up through it, it works like a dream. I used this method to automate proof-reading text layout for a cell-phone for a large number of different languages:
    sub SetErrorState { my($self) = shift; my($Sheet) = $self->{SHEET}; my($row, $col, $err) = @_; my $range = sprintf("%c%d", ord('A') + $col, $row); my $cell = $Sheet->Range($range); if($err) { $cell->ClearComments(); $cell->AddComment($err); $cell->Comment->{Visible} = 0; $cell->Interior->{ColorIndex} = 6; } else { $cell->Interior->{ColorIndex} = xlNone; $cell->ClearComments(); } }

    You might spot the ColorIndex thing - that was a bitch... Excel version dependant and all...

    Cheers,

    ---Lars

      Folks, Thanks everyone for fast response. I will experiment these methods. Regards, -Monir