Chart.Location(XlChartLocation, Object) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 Chart 控制項移至新位置。
public Microsoft.Office.Interop.Excel.Chart Location (Microsoft.Office.Interop.Excel.XlChartLocation Where, object Name);
abstract member Location : Microsoft.Office.Interop.Excel.XlChartLocation * obj -> Microsoft.Office.Interop.Excel.Chart
Public Function Location (Where As XlChartLocation, Optional Name As Object) As Chart
參數
- Where
- XlChartLocation
XlChartLocation. 圖表移動的目的地。
- Name
- Object
如果 Where
為 xlLocationAsObject ,則為內嵌圖表的工作表名稱,如果 Where
為 xlLocationAsNewSheet,則為新工作表的名稱。
傳回
範例
下列程式代碼範例會 Chart 建立 ,然後使用 Location 方法將圖表移至名為 “Sales” 的新工作表。
private void MoveChartToNewSheet()
{
this.Range["A1", "A5"].Value2 = 22;
this.Range["B1", "B5"].Value2 = 55;
Microsoft.Office.Tools.Excel.Chart chart1 =
this.Controls.AddChart(this.Range["D2", "H12"],
"chart1");
chart1.SetSourceData(this.Range["A1", "B5"],
Excel.XlRowCol.xlColumns);
chart1.ChartType = Excel.XlChartType.xl3DColumn;
chart1.Location(Excel.XlChartLocation.xlLocationAsNewSheet,
"Sales");
}
Private Sub MoveChartToNewSheet()
Me.Range("A1", "A5").Value2 = 22
Me.Range("B1", "B5").Value2 = 55
Dim Chart1 As Microsoft.Office.Tools.Excel.Chart = _
Me.Controls.AddChart(Me.Range("D2", "H12"), "Chart1")
Chart1.SetSourceData(Me.Range("A1", "B5"), Excel.XlRowCol.xlColumns)
Chart1.ChartType = Excel.XlChartType.xl3DColumn
Chart1.Location(Excel.XlChartLocation.xlLocationAsNewSheet, "Sales")
End Sub
備註
如果您想要將圖表移至工作表上的另一個位置,請使用 Top 的ChartArea屬性和 Left 屬性。 您可以使用 屬性取得 ChartArea 的 ChartChartArea 物件。
選擇性參數
如需選擇性參數的資訊,請參閱 Office 方案中的選擇性參數。