LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use ActiveX Microsoft Office Excel Chart?

Does anyone know how to use "ActiveX Microsoft Office Excel Chart" from CVI 7.0? I tried with following code but it did not draw anything. HRESULT MakeChartInExcelActivexCtrl(void) { HRESULT error = 0; char szErrMsg[256]; // // Create a new chart with its own worksheet // ExcelRpt_ChartNew(workbookHandle,-1,&chartsheetHandle); // SetWaitCursor (1); // // Open new Range for Worksheet // error = CA_VariantSetCString (&MyCellRangeV, EXCEL_ARRAY_OF_CELLS); error = Excel_WorksheetRange (ExcelWorksheetHandle, NULL, MyCellRangeV, CA_DEFAULT_VAL, &ExcelRangeHandle); CA_VariantClear(&MyCellRangeV); if (error<0) { CA_GetAutomationErrorString(error, szErrMsg, sizeof(szErrMsg) ); goto Error; } error = Excel_GetProperty (excelChart, NULL, Excel_WindowActiveChart, CAVT_OBJHANDLE, &ExcelChartHandle); if (error<0) { CA_GetAutomationErrorString(error, szErrMsg, sizeof(szErrMsg) ); goto Error; } // // Create a XY scatter chart using the data we wrote to the worksheet as its data source. // error = ExcelRpt_ChartWizard(ExcelChartHandle, ExcelWorksheetHandle, EXCEL_ARRAY_OF_CELLS, ExRConst_GalleryXYScatter, ExRConst_Columns, 0, 0, 0, 0, "Filtered Data Chart", "", "Weather Data", NULL); if (error<0) { CA_GetAutomationErrorString(error, szErrMsg, sizeof(szErrMsg) ); goto Error; } // // Change the plot lines to not display markers and smooth out // the plot lines. This is one of the plot styles available in Excel. // error = ExcelRpt_SetChartAttribute (ExcelChartHandle, ER_CH_ATTR_CHART_TYPE, ExRConst_XYScatterSmoothNoMarkers); if (error<0) { CA_GetAutomationErrorString(status, szErrMsg, sizeof(szErrMsg) ); goto Error; } Error: SetWaitCursor (0); CA_VariantClear(&MyCellRangeV); CA_VariantClear(&MyVariant); ClearObjHandle (&ExcelRangeHandle); ClearObjHandle (&ExcelChartHandle); ClearObjHandle (&ExcelChartObjHandle); ClearObjHandle (&ExcelChartsHandle); if (error < 0) ReportAppAutomationError (error); return 0; }
0 Kudos
Message 1 of 3
(3,528 Views)

There are various examples on Microsoft's website on how to automate Excel from VB6, C++, VB.NET, and C#. Choose one for the language that you are most familiar with and use it as a basis.

 

It is helpful to understand the Excel Object Model, and that is also on Microsoft's website.

 

 

0 Kudos
Message 2 of 3
(3,520 Views)

I use C:\Program Files\National Instruments\CVI90\toolslib\activex\excel\excelreport.fp to  build/modify excel report.there is very detail configuration in this function moudule , hope it can help you 

Sonic

Diffrent Strokes for Different Folks
0 Kudos
Message 3 of 3
(3,496 Views)