LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ExcelReportDemo Sample Project Question: Defaults to Sheet 4

Solved!
Go to solution

Hello Labwindows Community,

 

I wanted to understand the project, "Excelreportdemo" in CVI2012\samples\activex\excel\excelreportdemo.prj. Something that I couldn't understand is when I run the GUI, it always appears to open up to Sheet 4. I used the following set of functions on another program as well and saw that it would open to Sheet 4 as well.

 

static CAObjHandle applicationHandle = 0;
static CAObjHandle worksheetHandle = 0;
static CAObjHandle workbookHandle = 0;

 

error = ExcelRpt_ApplicationNew(1, &applicationHandle);
if (error<0)
{
MessagePopup (APP_AUTOMATION_ERR, LAUNCHERR);
goto Error;
}
ExcelRpt_WorkbookNew(applicationHandle, &workbookHandle);
ExcelRpt_WorksheetNew(workbookHandle, -1, &worksheetHandle);

 

Yet, I still see that it opens to Sheet 4. My questions are:

 

1.) Does anyone else see this behavior? 

2.) What do you suspect the cause is and how can we create an Excel file that only writes to one sheet?

 

Please let me know if there is any question I can answer. 

 

Cheers,

Vincent

0 Kudos
Message 1 of 2
(2,249 Views)
Solution
Accepted by topic author VincentTang

The underlying idea is that you are interfacing to Excel via ActiveX and inherit its working principles. In this case, when you create a new file in Excel it automatically has some sheets inside (I seem to remember that 3 is the default). Then you add a new sheet that becomes the 4th.

I normally use the Excel instrument instead of Excel Report one, and after creating a new file I connect to the first sheet and proceed to delete all existing sheets past that one; I suppose in Excel Report you can do the same and I think this is the only thing you can do.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 2
(2,231 Views)