Why am I getting an exception when I try to set the value of a cell in Excel using Perl's Win32::OLE? -


i getting error win32::ole<0.1709> error 0x80020009: "exception occurred" in propertyput "value" @ line 109.

the code in perl.

foreach $ref_array1 (@$array1) {     # loop through array  foreach $col1 (@$ref_array1) {         foreach $ref_array2 (@$array2) {     # loop through array         foreach $col2 (@$ref_array2) {              if ($col1 eq $col2)         {               line 109: **$worksheet1->cells($j,1)->{'value'} = $col1;**               $j++; 

any kind of appreciated. thankyou

the following incomplete example works (i.e., puts 5 in cell a1):

#!/usr/bin/perl  use strict; use warnings;  use win32::ole qw(in with); use win32::ole::const 'microsoft excel'; $win32::ole::warn = 3;  $excel = get_excel(); $excel->{visible} = 1;  $book = $excel->workbooks->add; $sheet = $book->worksheets->add; $sheet->{name} = 'perl win32-ole example';  $range = $sheet->cells(1,1); $range->{value} = 5; $range->autoformat;  sub get_excel {     $excel;      unless ( eval {             $excel = win32::ole->getactiveobject('excel.application')     }) {         die $@, "\n";     }      unless(defined $excel) {         $excel = win32::ole->new('excel.application', sub { $_[0]->quit })             or die "oops, cannot start excel: ",                    win32::ole->lasterror, "\n";     }     return $excel; } 

see perl win32::ole example.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -