Previous topicNext topic
Help > 开发指南 > Excel > API > 示例 > Chart图表 >
如何:将图表移动到图表工作表

下面的示例演示如何将现有图表从工作表移动到单独的图表工作表。为此,请为要移动的图表调用 ChartObject.MoveToNewChartSheet 方法。

若要将图表传输回包含源数据的工作表,请使用 ChartObject.MoveToWorksheet 方法。

Vb.Net
'在工作表上创建嵌入图表。
Dim chart As DevExpress.Spreadsheet.Charts.Chart = worksheet.Charts.Add(DevExpress.Spreadsheet.Charts.ChartType.Pie, worksheet("B2:C7"))
chart.TopLeftCell = worksheet.Cells("E2")
chart.BottomRightCell = worksheet.Cells("K15")

'将图表移动到图表工作表中。
Dim chartSheet As DevExpress.Spreadsheet.ChartSheet = chart.MoveToNewChartSheet("Chart")

C#
// 在工作表上创建嵌入图表。
DevExpress.Spreadsheet.Charts.Chart chart = worksheet.Charts.Add(DevExpress.Spreadsheet.Charts.ChartType.Pie, worksheet["B2:C7"]);
chart.TopLeftCell = worksheet.Cells["E2"];
chart.BottomRightCell = worksheet.Cells["K15"];

// 将图表移动到图表工作表中。
DevExpress.Spreadsheet.ChartSheet chartSheet = chart.MoveToNewChartSheet("Chart");