Hi all,
I'm trying to create a chart with series (multiple values for each chart column). I've managed to do so, only when the input parameters are read from an array in the memory. However, I want to create the chart with input from the same excel file (It can be done when using the Excel application) , with reference to the desired cells.
I'm using the code below, the basic idea was taken from previous post in this forum. I think I should be changing the last line in the code to create reference to cells within the same file.
I already tried with no success to copy the range as appeared in the Excel application when creating charts - "Sheet1!$A$1:$A$10" , then placing it in the VARIANT with the CA_VariantSetCString function.
Code:
-----------------------------------------
double data[] = {1,2,3,4,5,6};
LPSAFEARRAY safearray;
VARIANT safearrayV;
CAObjHandle Series;
ExcelObj_Series SeriesHandle;
EXCEL_APPLICATION_t ptr;
HRESULT ExecutionResult;
CAObjHandle Chart_Handle;
ERRORINFO ErrorInfo;
.
.
.
CA_Array1DToSafeArray (data, CAVT_DOUBLE, 6, &safearray);
CA_VariantSetSafeArray (&safearrayV, CAVT_DOUBLE, safearray);
ExecutionResult = ExcelRpt_ChartNew (ptr.ExcelWorkbookHandle, -1, &Chart_Handle);
ExecutionResult = Excel_ChartSeriesCollection(Chart_Handle,NULL,CA_DEFAULT_VAL,&Series);
ExecutionResult = Excel_SeriesCollectionNewSeries (Series, NULL, &SeriesHandle);
// This is where I put the series values:
ExecutionResult = Excel_SetProperty (SeriesHandle, &ErrorInfo, Excel_SeriesValues, CAVT_VARIANT, safearrayV);