Solved

WriteExcel AVERAGE containing variable as end Range

Posted on 2004-09-14
1
182 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
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 while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

732 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