NI Home
Cart Cart | Help
Hello Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI
You are here: 
NI Home > NI Developer Zone > NI Discussion Forums


Reply
Member
NiCoder
Posts: 49
0 Kudos

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; }
Active Participant nyc
Active Participant
Posts: 1,568
0 Kudos

Re: How to use ActiveX Microsoft Office Excel Chart?

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.

 

 

Member
菊花烧饼
Posts: 101
0 Kudos

Re: How to use ActiveX Microsoft Office Excel Chart?

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
By using this web site, you accept the Terms of Use for this web site. Please read these Terms of Use carefully before using any part of this site. Please go here for information on ni.com's copyright infringement policy.
My Profile | Privacy | Legal | Contact NI © 2011 National Instruments Corporation. All rights reserved.    |    E-Mail this Page E-Mail this Page