Solved

WriteExcel AVERAGE containing variable as end Range

Posted on 2004-09-14
1
179 Views
Last Modified: 2013-12-25
I have a perl program that uses Spreadsheet::WriteExcel.   I am using the AVERAGE and SUM functionality in the following manner:
      $worksheet->write('D'.$nplay, '=AVERAGE(D2:D26)',$average);
      $worksheet->write('E'.$nplay, '=AVERAGE(E2:D26)',$onezero);
      $worksheet->write('K'.$nplay, '=SUM(K2:K26)',$currency);
      $worksheet->write('O'.$nplay, '=SUM(O2:O26)',$currency);

This works fine most of the time but the problem is that the end of the range can change on occasion.  I need to be able to replace the "26" in each of the above examples with a variable.  I have tried the following and it does not seem to be correct syntax:
my $avg1="D".$avg;       
$worksheet->write('D'.$nplay, '=AVERAGE(D2:"$avg1")',$average);

any help here would be greatly appreciated.  
0
Comment
Question by:spoma
1 Comment
 
LVL 84

Accepted Solution

by:
ozo earned 50 total points
ID: 12061462
$worksheet->write('D'.$nplay, "=AVERAGE(D2:$avg1)",$average);
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question