04-22-2019 04:15 PM
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
Solved! Go to Solution.
04-23-2019 08:07 AM
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.