Excel.ChartCollection class
ワークシート上のすべてのグラフ オブジェクトのコレクション。
- Extends
注釈
プロパティ
context | オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。 |
count | ワークシート上のグラフの数を返します。 |
items | このコレクション内に読み込まれた子アイテムを取得します。 |
メソッド
add(type, source |
新しいグラフを作成します。 |
add(type |
新しいグラフを作成します。 |
get |
グラフ名を使用してグラフを取得します。 同じ名前の複数のグラフがある場合は、最初の 1 つが返されます。 |
get |
コレクション内での位置を基にグラフを取得します。 |
load(options) | オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
load(property |
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、 |
toJSON() | API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript |
プロパティの詳細
context
オブジェクトに関連付けられている要求コンテキスト。 これにより、アドインのプロセスが Office ホスト アプリケーションのプロセスに接続されます。
context: RequestContext;
プロパティ値
count
items
メソッドの詳細
add(type, sourceData, seriesBy)
新しいグラフを作成します。
add(type: Excel.ChartType, sourceData: Range, seriesBy?: Excel.ChartSeriesBy): Excel.Chart;
パラメーター
- type
- Excel.ChartType
グラフの種類を表します。 詳細は「Excel.ChartType
」をご覧ください。
- sourceData
- Excel.Range
Range
ソース データに対応する オブジェクト。
- seriesBy
- Excel.ChartSeriesBy
オプション。 列や行がグラフのデータ系列として使用される方法を指定します。 詳細は「Excel.ChartSeriesBy
」をご覧ください。
戻り値
注釈
例
// Add a chart of chartType "ColumnClustered" on worksheet "Charts"
// with sourceData from range "A1:B4" and seriesBy set to "auto".
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getItem("Sheet1");
const rangeSelection = "A1:B4";
const range = sheet.getRange(rangeSelection);
const chart = sheet.charts.add(
Excel.ChartType.columnClustered,
range,
Excel.ChartSeriesBy.auto);
await context.sync();
console.log("New Chart Added");
});
add(typeString, sourceData, seriesByString)
新しいグラフを作成します。
add(typeString: "Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Boxwhisker" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel", sourceData: Range, seriesByString?: "Auto" | "Columns" | "Rows"): Excel.Chart;
パラメーター
- typeString
-
"Invalid" | "ColumnClustered" | "ColumnStacked" | "ColumnStacked100" | "3DColumnClustered" | "3DColumnStacked" | "3DColumnStacked100" | "BarClustered" | "BarStacked" | "BarStacked100" | "3DBarClustered" | "3DBarStacked" | "3DBarStacked100" | "LineStacked" | "LineStacked100" | "LineMarkers" | "LineMarkersStacked" | "LineMarkersStacked100" | "PieOfPie" | "PieExploded" | "3DPieExploded" | "BarOfPie" | "XYScatterSmooth" | "XYScatterSmoothNoMarkers" | "XYScatterLines" | "XYScatterLinesNoMarkers" | "AreaStacked" | "AreaStacked100" | "3DAreaStacked" | "3DAreaStacked100" | "DoughnutExploded" | "RadarMarkers" | "RadarFilled" | "Surface" | "SurfaceWireframe" | "SurfaceTopView" | "SurfaceTopViewWireframe" | "Bubble" | "Bubble3DEffect" | "StockHLC" | "StockOHLC" | "StockVHLC" | "StockVOHLC" | "CylinderColClustered" | "CylinderColStacked" | "CylinderColStacked100" | "CylinderBarClustered" | "CylinderBarStacked" | "CylinderBarStacked100" | "CylinderCol" | "ConeColClustered" | "ConeColStacked" | "ConeColStacked100" | "ConeBarClustered" | "ConeBarStacked" | "ConeBarStacked100" | "ConeCol" | "PyramidColClustered" | "PyramidColStacked" | "PyramidColStacked100" | "PyramidBarClustered" | "PyramidBarStacked" | "PyramidBarStacked100" | "PyramidCol" | "3DColumn" | "Line" | "3DLine" | "3DPie" | "Pie" | "XYScatter" | "3DArea" | "Area" | "Doughnut" | "Radar" | "Histogram" | "Boxwhisker" | "Pareto" | "RegionMap" | "Treemap" | "Waterfall" | "Sunburst" | "Funnel"
グラフの種類を表します。 詳細は「Excel.ChartType
」をご覧ください。
- sourceData
- Excel.Range
Range
ソース データに対応する オブジェクト。
- seriesByString
-
"Auto" | "Columns" | "Rows"
オプション。 列や行がグラフのデータ系列として使用される方法を指定します。 詳細は「Excel.ChartSeriesBy
」をご覧ください。
戻り値
注釈
getItem(name)
グラフ名を使用してグラフを取得します。 同じ名前の複数のグラフがある場合は、最初の 1 つが返されます。
getItem(name: string): Excel.Chart;
パラメーター
- name
-
string
取得するグラフの名前。
戻り値
注釈
例
// Get the number of charts.
await Excel.run(async (context) => {
const charts = context.workbook.worksheets.getItem("Sheet1").charts;
charts.load('count');
await context.sync();
console.log("charts: Count= " + charts.count);
});
getItemAt(index)
コレクション内での位置を基にグラフを取得します。
getItemAt(index: number): Excel.Chart;
パラメーター
- index
-
number
取得するオブジェクトのインデックス値。 0 を起点とする番号になります。
戻り値
注釈
例
await Excel.run(async (context) => {
const lastPosition = context.workbook.worksheets.getItem("Sheet1").charts.count - 1;
const chart = context.workbook.worksheets.getItem("Sheet1").charts.getItemAt(lastPosition);
await context.sync();
console.log(chart.name);
});
load(options)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(options?: Excel.Interfaces.ChartCollectionLoadOptions & Excel.Interfaces.CollectionLoadOptions): Excel.ChartCollection;
パラメーター
読み込むオブジェクトのプロパティのオプションを提供します。
戻り値
load(propertyNames)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNames?: string | string[]): Excel.ChartCollection;
パラメーター
- propertyNames
-
string | string[]
読み込むプロパティを指定するコンマ区切り文字列または文字列の配列。
戻り値
例
await Excel.run(async (context) => {
const charts = context.workbook.worksheets.getItem("Sheet1").charts;
charts.load('items');
await context.sync();
for (let i = 0; i < charts.items.length; i++) {
console.log(charts.items[i].name);
}
});
load(propertyNamesAndPaths)
オブジェクトの指定されたプロパティを読み込むコマンドを待ち行列に入れます。 プロパティを読み取る前に、context.sync()
を呼び出す必要があります。
load(propertyNamesAndPaths?: OfficeExtension.LoadOption): Excel.ChartCollection;
パラメーター
- propertyNamesAndPaths
- OfficeExtension.LoadOption
propertyNamesAndPaths.select
は、読み込むプロパティを指定するコンマ区切り文字列で propertyNamesAndPaths.expand
、読み込むナビゲーション プロパティを指定するコンマ区切りの文字列です。
戻り値
toJSON()
API オブジェクトが に渡されたときにより便利な出力を提供するために、JavaScript toJSON()
メソッドを JSON.stringify()
オーバーライドします。 (JSON.stringify
さらに、渡される オブジェクトの メソッドを呼び出 toJSON
します)。元 Excel.ChartCollection
のオブジェクトは API オブジェクトですが、 toJSON
メソッドは、コレクションの項目から読み込まれたプロパティの浅いコピーを含む "items" 配列を含むプレーンな JavaScript オブジェクト (として Excel.Interfaces.ChartCollectionData
型指定) を返します。
toJSON(): Excel.Interfaces.ChartCollectionData;
戻り値
Office Add-ins
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示