473,770 Members | 6,105 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Perl - Win32::OLE - Excel Formulas

11 New Member
I am a Perl Programmer & i am using WIN32::OLE for Excel operations.

I wanted to use conditional formulas like 'if' in excel via Perl.

Thanks in Advance.
Mar 31 '11 #1
13 4689
miller
1,089 Recognized Expert Top Contributor
I personally would use Spreadsheet::Wr iteExcel as Win32::OLE does not provide great documentation.

At the very least, maybe you could create a test excel file with functions and examine it using Win32::OLE to determine how they are included.

- Miller
Mar 31 '11 #2
Prasanna CRN
11 New Member
Hi Miller,
Thanks for your Interest & I found the answer.

Expand|Select|Wrap|Line Numbers
  1. "=IF(RC[$prev]>RC[$curr],RC[$prev]-RC[$curr],\"PASS\")"
  2.  
The reason why i am using Win32::OLE is, no need of additional Module Installation.
Apr 1 '11 #3
miller
1,089 Recognized Expert Top Contributor
Of course, Just note that anytime you want to use quotes " instead of an interpolated string, you can use the qq operator instead.

Expand|Select|Wrap|Line Numbers
  1. qq{=IF(RC[$prev]>RC[$curr],RC[$prev]-RC[$curr],"PASS")}
  2.  
Apr 1 '11 #4
Prasanna CRN
11 New Member
Thanks Miller.

But Folks, any idea on Arithmetic Operation with Strings?

Ex : I can do auto increment of string : my $a = 'A';
$a ++ ; #Will give 'B'

Like that, i want to do : $a += 5 ; #I expect 'F', but perl throws error on this. Any idea on my thing?
Apr 2 '11 #5
RonB
589 Recognized Expert Moderator Contributor
When you do $a++, perl will increment the ascii value, but when you do $a += 5, you're attempting to add a numerical number which is not the same.

To accomplish what you want, you'd need to do this.
Expand|Select|Wrap|Line Numbers
  1. my $letter = 'a';
  2. $letter = chr(ord($letter)+5);
Apr 2 '11 #6
miller
1,089 Recognized Expert Top Contributor
As RonB pointed out, the fact that the increment ++ and decrement -- operators work on strings is a special feature. To get the same behavior out of += or any other operator would require overloading them.

The best method is to just use the method that RonB demonstrated.

- Miller
Apr 3 '11 #7
Prasanna CRN
11 New Member
Thanks Guys for your Awesome Response!!!

RonB,
I accept that. But even with this option i have a problem:
my $letter = 'A';
my $test;

for ($i = 1; $i <= 100; $i++){

$test = chr(ord($letter ));
print "Orig Char : $letter; Exp Char : $test\n";
$letter++;
}

This will fine upto 26 (A to Z), After 26th Iteration, $letter will become 'AA' where the function will fail (Since it will take 1 char as argument).

Any alternative way to address this problem.
Apr 4 '11 #8
miller
1,089 Recognized Expert Top Contributor
Yes, if you increment a string it will go from A to Z and then to AA AB, etc. You say that's not what you want, but you haven't described what your ideal behavior actually is?

What are you wanting your string incrementor to do? In theory you're going through 100 values, what do you want them to be?
Apr 4 '11 #9
Prasanna CRN
11 New Member
Miller,
At the begining i mentioned that i am working in Excel.
The Excel Cells Starts from 'A' & it goes like AA - AZ, BA - BZ & so on.. This is my Use case!

Hope it will narrow your ideas.
Apr 4 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
13106
by: M. David Allen | last post by:
Hello, I've been using ActiveState's ActivePerl to generate Excel spreadsheets using the Win32::OLE module. The rudimentary examples that are out there on the web show the way to set up specific ranges and enter data into cells, but what I'm looking for at this point is how to set the background color of cells. Does anybody know how to do this with Win32::OLE? If this module maps to Microsoft's API, is there any complete...
2
6180
by: usenet | last post by:
Problem installing Win32::OLE under Cygwin. I have searched the web and found little documentation on installation procedure. Please help. I'd like to get Win32::OLE working under cygwin. Cygwin perl 5.8.6-4 Windows XP SP1
3
41792
by: sandycat05 | last post by:
Hello all, I am a new Perl programmer. Below is the beginnings of a code that I am using to manipulate an Excel spreadsheet via Perl using win32::OLE. However, what I'd like to do is the following: instead of either opening a file or creating a new one, I'd like to do BOTH. I was thinking of creating a loop where I could basically say something like: if $excelfile exists, then open $excelfile, otherwise, create a new workbook named...
2
4438
by: momukhtar | last post by:
I am using Win32::OLE to write a perl script which opens an excel file. That excel file is password protected and everytime i run that script dialog box pops up and I have to click on Read-Only then my script executes. Is there any way I can specify the readonly attribute in my code so i dont have to click on read only.
8
5031
by: dilipkvarma | last post by:
Hi All, I am trying to create a subtotal in an Excel sheet through Perl script. Some how I am not able to make it work. Here is what I wrote $Sheet->Activate; $Range = $Sheet->Range("A2:C$Row"); $Range->Select;
8
36586
by: rssd | last post by:
can somebody help me. I'm trying to read some excel files but i'm always getting this error No type library matching "Microsoft Excel" found at D:\Genes_datasets\exp.pl line 4 Win32::OLE(0.16): GetOleTypeLibObject() Not a Win32::OLE::TypeLib object at C:/Perl/site/lib/Win32/OLE/Const.pm line 45. Died at D:\Genes_datasets\exp.pl line 6. i don't ve microsoft excel but open office installed, i think that could be a problem. But these...
1
6207
by: mohanprasadgutta | last post by:
Hi, I need help to open a password protected excel file in perl using Win32:OLE. when I tried to open file in normal way at the time of program execution it is prompting me to enter password. I am giving the script i used for opening excel file.. So i want to know how to provide password parameter while opening the file. use strict; use Win32::OLE; use Win32::OLE::Const 'Microsoft Excel'; use Win32::OLE::Variant qw(:DEFAULT nothing);
1
1626
by: Tension | last post by:
Hi, I have written a development automation tool that needs to be distributed to 20-odd developers using Windows XP workstations. Is there a free Perl distribution that includes "Win32::OLE" by default? Best Regards, Adam S
6
6480
by: poolboi | last post by:
hi all, i've got the following program that needs yr help: use Win32::OLE; # use existing instance if Excel is already running eval {$ex = Win32::OLE->GetActiveObject('Excel.Application')}; die "Excel not installed" if $@; unless (defined $ex) {
1
4521
by: user1357 | last post by:
Hi all, i am trying to run the following code use strict; use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel';
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8887
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6679
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5313
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5452
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3972
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2817
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.