LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having trouble sizing multiple graphs using a For Loop in Excel.

I am creating multiple graphs in Excel using LabVIEW but I can only set the size for the first graph.  The others are ignored.  I am using the Excel Insert Graph Vi.  I can change the position of al 4 graphs and i can change the size of the first graph created but not the others.  Simply create and save a blank Excel workbook and use it when it prompts for the file.  Here is my my code.  Will someone please let me know what is going on.  Thanks.
0 Kudos
Message 1 of 5
(3,513 Views)

Hello,

I was able to reproduce this problem in both LabVIEW 7.1 and 8.0, with both Office XP and 2003.  I'm still investigating, but it looks like it may be a problem with the AddOLEObject method in Excel.  I'm noticing on those subsequent charts, that when the object first gets added, you see it start off at the right size, but it quickly resizes down to the default size.  This all happens when the AddOLEObject method runs, which implies to me that the problem may be outside our control.  I will continue investigating tomorrow, however, and let you know what else I find out.

-D

0 Kudos
Message 2 of 5
(3,490 Views)
I have the same problem when creating multiple graphs in Excel using the Excel Insert Graph VI. Only the first one can be resized. And when I'm using the Disable Structure to take away the creating of the first graph, my second graph will be sized according to my inputs without any more changes of the code. I'm confused over this and can't find any explanation.
0 Kudos
Message 3 of 5
(3,481 Views)

Having investigated this issue a little further, I still don't have a resolution, although I do understand it a little more.  The AddOLEObject method is definitely at fault, and it starts acting squirrely after the Excel_Insert_Chart.vi runs.  If I just add the OLE object into the spreadsheet without assigning any graph contents, all the objects are sized correctly.  It's only after a chart has been added to the OLE object do the subsequent objects get resized improperly.  Furthermore, I tried writing the size of the object again immediately after creating it, and it was resized, but to a completely wrong size (usually much bigger than the attempted size).  So for now, the only workaround I have for you is to open and close the report after adding each graph.  This is tedious (and it results in window flashing), but it's the only reliable workaround I have...I attached a VI to this post that illustrates what I'm talking about...the VI is saved in LabVIEW 7.0 format.

I will look further into this issue whenever we start working on the next version of the toolkit.  If you wish to investigate it further yourself, check out vi.lib\addons\_office\excel.llb\Excel Insert Graph.vi.  This is where the width/height of the OLE Object are defined.  Also check out vi.lib\addons\_office\_exclsub.llb\Excel_Insert_Chart.vi...this is where the actual chart contents get added. 

-D

 

0 Kudos
Message 4 of 5
(3,469 Views)
If anyone is still following this thread, I have discovered a solution to the problem of resizing multiple graphs in Excel with the Report Generation Toolkit.  The problem seems to occur because subsequent graphs that are added to the report are configured to "Lock Aspect Ratio", which means you cannot assign a width and height to the graph that would violate its initial width/height proportions.  I was able to get around this behavior by defining the object's position and dimensions after creating the object, as opposed to defining them at the same time the object was created.  This problem will be fixed in a future release of the Report Generation Toolkit.  For now, you can fix the problem yourself by modifying vi.lib\addons\_office\excel.llb\Excel Insert Graph.vi.  Here is a screenshot of the affected area of code as it is currently implemented:
 
 
And here is a screenshot of what the code looks like after my modifications that fix the problem:
 
 
By assigning the dimensions after turning off the "Lock Aspect Ratio" feature, we see that all the subsequent graphs are sized correctly.
 
Please let me know if you have any questions on this fix.
 
-D

Message Edited by Darren on 07-06-2006 04:48 PM

Download All
Message 5 of 5
(3,395 Views)