S
stevo
I am using Microsoft Viusal C++ .Net (unmanaged MFC Application)
and Excel 2002.
I have been able to create and Excel worksheet and fill it with data
from my C++ program. However, I can't figure out how to create a
chart.
I can't find enough documentation on CChart to figure out how to
create a chart.
Can someone show me a simply example or point me to the right
literature?
Thanks
Stephen
Below is my code that creates the excel sheet and populates it with
data:
CApplication oExcel;
CWorkbook oBook;
CWorkbooks oBooks;
CWorksheets oSheets;
CWorksheet oSheet;
CRange oRange;
CChart oChart;
COleVariant covOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
oExcel.CreateDispatch("Excel.Application");
oBooks = oExcel.get_Workbooks();
oBook = oBooks.Add(covOptional);
oSheets = oBook.get_Worksheets();
oSheet = oSheets.get_Item(COleVariant((short)1));
oChart = oBook.get_Charts();
oExcel.put_Visible(TRUE);
oExcel.put_UserControl(TRUE);
COleSafeArray saRet;
COleSafeArray saDateTime;
COleSafeArray saPhaseAdjustmentAngles;
DWORD numElements[2];
numElements[0] = NumberOfCallIns;
numElements[1] = NumberOfCallIns;
// Get a range of data.
oRange = oSheet.get_Range(COleVariant("C13"),covOptional);
oRange = oRange.get_Resize(COleVariant((short)NumberOfCallIns),COleVariant((short)24));
saRet.Create(VT_R8,2,numElements);
long index[2];
for (int iRow = 1; iRow < NumberOfCallIns; iRow++) {
for (int iCol = 1; iCol <= 24; iCol++) {
index[0]=iRow-1;
index[1]=iCol-1;
outBug << iRow << "\t" << iCol << endl;
saRet.PutElement(index,&StoreValuesForOutput[iCol][iRow]);
and Excel 2002.
I have been able to create and Excel worksheet and fill it with data
from my C++ program. However, I can't figure out how to create a
chart.
I can't find enough documentation on CChart to figure out how to
create a chart.
Can someone show me a simply example or point me to the right
literature?
Thanks
Stephen
Below is my code that creates the excel sheet and populates it with
data:
CApplication oExcel;
CWorkbook oBook;
CWorkbooks oBooks;
CWorksheets oSheets;
CWorksheet oSheet;
CRange oRange;
CChart oChart;
COleVariant covOptional(DISP_E_PARAMNOTFOUND,VT_ERROR);
oExcel.CreateDispatch("Excel.Application");
oBooks = oExcel.get_Workbooks();
oBook = oBooks.Add(covOptional);
oSheets = oBook.get_Worksheets();
oSheet = oSheets.get_Item(COleVariant((short)1));
oChart = oBook.get_Charts();
oExcel.put_Visible(TRUE);
oExcel.put_UserControl(TRUE);
COleSafeArray saRet;
COleSafeArray saDateTime;
COleSafeArray saPhaseAdjustmentAngles;
DWORD numElements[2];
numElements[0] = NumberOfCallIns;
numElements[1] = NumberOfCallIns;
// Get a range of data.
oRange = oSheet.get_Range(COleVariant("C13"),covOptional);
oRange = oRange.get_Resize(COleVariant((short)NumberOfCallIns),COleVariant((short)24));
saRet.Create(VT_R8,2,numElements);
long index[2];
for (int iRow = 1; iRow < NumberOfCallIns; iRow++) {
for (int iCol = 1; iCol <= 24; iCol++) {
index[0]=iRow-1;
index[1]=iCol-1;
outBug << iRow << "\t" << iCol << endl;
saRet.PutElement(index,&StoreValuesForOutput[iCol][iRow]);