BOOL Cxlsx::TempChar_LineChart(DWORD row, DWORD col, string &error_info)
{
int width = 600;
int height = 350;
Cmylib mylib;
if((row < 1) || (col < 1))
return FALSE;
CComVariant Invoke_res;
try
{
IDispatchPtr pIDispatch = NULL;
//IDispatch* pIDispatch = NULL;
SeriesPtr pSeries = NULL;
DISPID dispid;
BSTR name;
DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
pActive_sheet->Range["A1"]["A1"]->Select();
ShapePtr pShapePtr = pActive_sheet->Shapes->AddChart(xlLine, 0, 0, width, height);
_ChartPtr pChartPtr = pShapePtr->GetChart();
pIDispatch = pChartPtr->SeriesCollection();
name = SysAllocString(L"NewSeries");
pIDispatch->GetIDsOfNames(IID_NULL, &name, 1, GetUserDefaultLCID(), &dispid);
string sheet_name("Data");
pChartPtr->ApplyLayout(1);
pChartPtr->ChartTitle->Text = "VOUT_OS";
//pChartPtr->Axes(xlValue, xlPrimary)
for(int serial = 0; serial < 5; ++serial){
pIDispatch->Invoke(dispid, IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD, &dispparamsNoArgs, &Invoke_res, NULL, NULL);
pSeries = Invoke_res;
string str_Values;
str_Values = "='" + sheet_name + "'!$" + mylib.convert_column_format(16) + "$" + mylib.int2str(48 + 5 * serial);
str_Values = str_Values + ":$" + mylib.convert_column_format(16) + "$" + mylib.int2str(48 + 5 * serial + 4);
string str_XValues;
str_XValues = "='" + sheet_name + "'!$" + mylib.convert_column_format(10) + "$" + mylib.int2str(48 + 5 * serial);
str_XValues = str_XValues + ":$" + mylib.convert_column_format(10) + "$" + mylib.int2str(48 + 5 * serial + 4);
pSeries->Name = mylib.int2str(serial).c_str();
pSeries->Values = str_Values.c_str();
pSeries->XValues = str_XValues.c_str();
//str_values = "=Sheet1!$I$6:$I$10"
//pSeries->XValues = "{25,45,65,85,105}";
//if(serial == 0)
// pSeries->Values = "='SC8329-TEMP'!$P48:$P52";
//else
// pSeries->Values = "='SC8329-TEMP'!$P53:$P57";
}
//pIDispatch->Invoke(dispid, IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD, &dispparamsNoArgs, &Invoke_res, NULL, NULL);
//pSeries = Invoke_res;
//pSeries->Name = "1";
//pSeries->Values = "{5,6,7}";
//pSeries->XValues = "{-20,25,60}";
//pIDispatch->Invoke(dispid, IID_NULL, GetUserDefaultLCID(), DISPATCH_METHOD, &dispparamsNoArgs, &Invoke_res, NULL, NULL);
//pSeries = Invoke_res;
//pSeries->Name = "2";
//pSeries->Values = "{6,7,8}";
//pSeries->XValues = "{-20,25,60}";
pShapePtr = NULL;
pChartPtr = NULL;
pSeries = NULL;
pIDispatch = NULL;
SysFreeString(name);
}
catch (_com_error& error)
{
error_info = error.ErrorMessage();
return FALSE;
}
return TRUE;
}