http://www.perlmonks.org?node_id=226917


in reply to Using Win32::OLE and Excel - Tips and Tricks

Hi cacharbe,
I'm trying to fill up an excel sheet following a format wich is stored in an excel template (just in a regular excel file).
This tutorial is really help me, but there's still something hard to do : find out wich cells are merged in the template and merging the matching cells in the output file.
I have found the MergeCells property, a boolean that tells you if there are a merged cell in the parent object. MergeArea returns a range of merged cells containing a given cell. My problem is I cant find a way to extract the row & col indexes to reproduce the merge on the output file.
Any idea about, it.
mehdi aziz
mehdiaziz@lycos.com
  • Comment on Re: Using Win32::OLE and Excel - Tips and Tricks

Replies are listed 'Best First'.
Re^2: Using Win32::OLE and Excel - Tips and Tricks
by Anonymous Monk on Sep 20, 2004 at 12:24 UTC
    I have a problem with this:

    my $indents = $Sheet->Range( "A1:B2" )->{'IndentLevel'};

    If i use 'Value' in stead of IndentLevel everything works fine.

    Any ansers?
Re: Re: Using Win32::OLE and Excel - Tips and Tricks
by Anonymous Monk on May 03, 2004 at 11:03 UTC
    Hi aziz, Sorry that I am asking you a question instead of an answer.Can u give me the syntax to merge cells in excel using perl(with OLEs)? Thanks, Sree
      I know how to read an Excel cell's hyperlink value. What is the syntax to set or change a cell's hyperlink value? -docuSwear

        Here is a short example:
        #!/usr/bin/perl -w use strict; use Cwd; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; my $application = Win32::OLE->new("Excel.Application"); my $workbook = $application->Workbooks->Add; my $worksheet = $workbook->Worksheets(1); # Write a hyperlink my $range = $worksheet->Range("B2:B2"); $worksheet->Hyperlinks->Add({Anchor => $range, Address => "http://www.perl.com/"}); # Get current directory using Cwd.pm $workbook->SaveAs({FileName => cwd() . '/win32ole.xls'}); $workbook->Close; __END__

        --
        John.