代碼: 選擇全部
void __fastcall Tform1::Button1Click(TObject *Sender)
{
Variant ex, wb, ws, ch;
ex = CreateOleObject("Excel.Application");
wb = ex.OlePropertyGet("WorkBooks").OleFunction("Open", "C:\1.xls");
ws = wb.OlePropertyGet("WorkSheets", "Sheet1");
ex.OlePropertySet("Visible", true);
ch = ex.OlePropertyGet("Charts").OleFunction("Add");
ch.OlePropertySet("ChartType", 51);
ch.OleFunction("SetSourceData", ws.OlePropertyGet("Range","A1:B7"), 2);
ch.OleFunction("Location", 2, "Sheet1");
}
附上相關的資料與討論:
http://www.progz.ru/viewtopic.php?t=1237
http://www.cbuilder.ru/WinLesson/bles1_2.htm
參考連結:
http://delphi.ktop.com.tw/topic.asp?TOPIC_ID=34385