I am totally new to perl. I have a retro-engineering mission about a software developed long time ago, and only in perl. Why ? Because performance are actually not good . What are we doing with the software ? Extraction from a database to an excel document we are using to make dashboards.
We have found out that the problem of slowness is coming from Excel. Each time we are writing in an excel cell, it calculate all our formula. So my goal here is to disable the automatic calculation of excel with the Win32::OLE library.
So first I have displayed the value I wanted to gave to the Calculation variable :
and the result ismy $xl = Win32::OLE::Const->Load("Microsoft Excel"); printf "Excel type library contains %d constants:\n", scalar keys +%$xl; foreach my $Key (sort keys %$xl) { if ($Key eq "xlCalculationManual" || $Key eq "xlCalculationAut +omatic" ){ print "$Key = $xl->{$Key}\n"; } }
Excel type library contains 2177 constants: xlCalculationAutomatic = -4105 xlCalculationManual = -4135
This is what I have tried (I can just copy this part of the code but there are other lines) :
use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Word'; use Win32::OLE::Const 'Microsoft Excel'; my $xl = Win32::OLE::Const->Load("Microsoft Excel"); my $excel = Win32::OLE->CreateObject('Excel.Application') || die $!; $excel->{DisplayAlerts}=0; $excel->{Calculation}=-4135;
But it doesn't work and I can't understand why... Value of $excel->{Calculation} is -2146826246 and stay the same. I have also tried $excel->{Calculation}=xlManual; or $excel->{Calculation}=xlCalculationManual; but it doesn't work neither.
So if someone could tell me what I am doing wrong... it would be very helpful :). I know I can call a vba macro from perl, but I want to do it only in perl.
In reply to Win32::OLE disable calculation by Psylo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |