delphi读取excel图表中的公式内容 [Vsun你好](100)

Unregistered / Unconfirmed
GUEST, unregistred user!
根据Sheet2工作表中的数据做一簇状柱形图:数据产生区域为A4到D11,系列产生在列。图表标题为“学生成绩统计”。分类轴(X)轴坐标标题为“姓名”,数值(Y)轴标题为“分数”。图表显示在Sheet3工作表中。如何取出:“序列公式”?本题3个答案: (PlotFormulaR1C1) (1) =SERIES(Sheet2!R4C3,Sheet2!R5C1:R11C1,Sheet2!R5C3:R11C3,1) (2) =SERIES(Sheet2!R4C2,Sheet2!R5C1:R11C1,Sheet2!R5C2:R11C2,2) (3) =SERIES(Sheet2!R4C2,Sheet2!R5C1:R11C1,Sheet2!R5C2:R11C2,3)
 
V

Vsun

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.Button1Click(Sender: TObject);const xlColumnClustered = 51; xlLocationAsObject = 2; xlColumns = 2; xlCategory = 1; xlPrimary = 1; xlValue = 2;var MyExcel, MyWorkbook, MyChart, MyRange: Variant;begin MyExcel := CreateOleObject('Excel.Application'); MyExcel.Visible := True; MyWorkbook := MyExcel.Workbooks.Open('d:/abc.xls'); MyRange := MyWorkbook.Sheets['Sheet2'].Range['A4:D11']; MyChart := MyWorkbook.Charts.add; MyChart.ChartType := xlColumnClustered; //设定类型 MyChart.SetSourceData(MyRange, xlColumns); //指定数据源 MyChart.HasTitle := True; //显示标题 MyChart.ChartTitle.Characters.Text := '学生成绩统计'; MyChart.Axes(xlCategory, xlPrimary).HasTitle := True; MyChart.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text := '姓名'; MyChart.Axes(xlValue, xlPrimary).HasTitle := True; MyChart.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text := '分数'; for i := 1 to MyChart.SeriesCollection.Count do ShowMessage(MyChart.SeriesCollection.Formula); //显示公式 MyChart.Location(xlLocationAsObject, 'Sheet3'); MyWorkbook.close; MyExcel.quit;end;
 

Unregistered / Unconfirmed
GUEST, unregistred user!
接受答案了.
 
Top Bottom