Excel.ChartSeriesBy enum

系列が行別か列別かを指定します。 Excel on desktop では、"auto" オプションによってソース データ図形が検査され、データが行または列によって自動的に推測されます。 Excel on the webでは、"auto" は既定で "columns" になります。

注釈

[ API セット: ExcelApi 1.1 ]

// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-data-source.yaml

await Excel.run(async (context) => {
  // Create a new worksheet called "Sample" and activate it.
  context.workbook.worksheets.getItemOrNullObject("Sample").delete();
  const sheet = context.workbook.worksheets.add("Sample");
  
  // Create an a table named SalesTable on the Sample worksheet.
  let expensesTable = sheet.tables.add("A1:E1", true);
  expensesTable.name = "SalesTable";

  expensesTable.getHeaderRowRange().values = [["Product", "Qtr1", "Qtr2", "Qtr3", "Qtr4"]];        
  expensesTable.rows.add(null, [
    ["Frames", 5000, 7000, 6544, 4377],
    ["Saddles", 400, 323, 276, 651],
    ["Brake levers", 12000, 8766, 8456, 9812],
    ["Chains", 1550, 1088, 692, 853],
    ["Mirrors", 225, 600, 923, 544],
    ["Spokes", 6005, 7634, 4589, 8765]
  ]);
  
  sheet.getUsedRange().format.autofitColumns();
  sheet.getUsedRange().format.autofitRows();
  sheet.activate();

  // Create a line chart based on data from SalesTable.
  let dataRange = sheet.getRange("A1:E7");
  let chart = sheet.charts.add("Line", dataRange, Excel.ChartSeriesBy.rows);

  // Position and style the chart.
  chart.setPosition("A15", "E30");
  chart.legend.position = "Right";
  chart.legend.format.fill.setSolidColor("white");

  await context.sync();
});

フィールド

auto = "Auto"

Excel on desktop では、"auto" オプションによってソース データ図形が検査され、データが行または列によって自動的に推測されます。 Excel on the webでは、"auto" は既定で "columns" になります。

columns = "Columns"
rows = "Rows"