Add Chart.(Microsoft Excel Office Scripts)

Japanese version.

Introduction to adding graphs in Office scripts.

Operations

workbook.getWorksheet("Sheet name").addChart(
Chart type,Range of source data,Series)
function main(workbook: ExcelScript.Workbook) {

  let chart = workbook.getWorksheet("Test").addChart(ExcelScript.ChartType.columnClustered,
    workbook.getWorksheet("Test").getRange("A1:A3"),
    ExcelScript.ChartSeriesBy.columns
  );

}

Argument

ExcelScript

The first argument is the type of graph to be added.

  • ExcelScript.ChartType.area
  • ExcelScript.ChartType.areaStacked
  • ExcelScript.ChartType.areaStacked100
  • ExcelScript.ChartType.barClustered
  • ExcelScript.ChartType.barOfPie
  • ExcelScript.ChartType.barStacked
  • ExcelScript.ChartType.barStacked100
  • ExcelScript.ChartType.boxwhisker
  • ExcelScript.ChartType.bubble
  • ExcelScript.ChartType.bubble3DEffect
  • ExcelScript.ChartType.columnClustered
  • ExcelScript.ChartType.columnStacked
  • ExcelScript.ChartType.columnStacked100
  • ExcelScript.ChartType.coneBarClustered
  • ExcelScript.ChartType.coneBarStacked
  • ExcelScript.ChartType.coneBarStacked100
  • ExcelScript.ChartType.coneCol
  • ExcelScript.ChartType.coneColClustered
  • ExcelScript.ChartType.coneColStacked
  • ExcelScript.ChartType.coneColStacked100
  • ExcelScript.ChartType.cylinderBarClustered
  • ExcelScript.ChartType.cylinderBarStacked
  • ExcelScript.ChartType.cylinderBarStacked100
  • ExcelScript.ChartType.cylinderCol
  • ExcelScript.ChartType.cylinderColClustered
  • ExcelScript.ChartType.cylinderColStacked
  • ExcelScript.ChartType.cylinderColStacked100
  • ExcelScript.ChartType.doughnut
  • ExcelScript.ChartType.doughnutExploded
  • ExcelScript.ChartType.funnel
  • ExcelScript.ChartType.histogram
  • ExcelScript.ChartType.invalid
  • ExcelScript.ChartType.line
  • ExcelScript.ChartType.lineMarkers
  • ExcelScript.ChartType.lineMarkersStacked
  • ExcelScript.ChartType.lineMarkersStacked100
  • ExcelScript.ChartType.lineStacked
  • ExcelScript.ChartType.lineStacked100
  • ExcelScript.ChartType.pareto
  • ExcelScript.ChartType.pie
  • ExcelScript.ChartType.pieExploded
  • ExcelScript.ChartType.pieOfPie
  • ExcelScript.ChartType.pyramidBarClustered
  • ExcelScript.ChartType.pyramidBarStacked
  • ExcelScript.ChartType.pyramidBarStacked100
  • ExcelScript.ChartType.pyramidCol
  • ExcelScript.ChartType.pyramidColClustered
  • ExcelScript.ChartType.pyramidColStacked
  • ExcelScript.ChartType.pyramidColStacked100
  • ExcelScript.ChartType.radar
  • ExcelScript.ChartType.radarFilled
  • ExcelScript.ChartType.radarMarkers
  • ExcelScript.ChartType.regionMap
  • ExcelScript.ChartType.stockHLC
  • ExcelScript.ChartType.stockOHLC
  • ExcelScript.ChartType.stockVHLC
  • ExcelScript.ChartType.stockVOHLC
  • ExcelScript.ChartType.sunburst
  • ExcelScript.ChartType.surface
  • ExcelScript.ChartType.surfaceTopView
  • ExcelScript.ChartType.surfaceTopViewWireframe
  • ExcelScript.ChartType.surfaceWireframe
  • ExcelScript.ChartType.treemap
  • ExcelScript.ChartType.waterfall
  • ExcelScript.ChartType.xyscatter
  • ExcelScript.ChartType.xyscatterLines
  • ExcelScript.ChartType.xyscatterLinesNoMarkers
  • ExcelScript.ChartType.xyscatterSmooth
  • ExcelScript.ChartType.xyscatterSmoothNoMarkers

Range of source data

The second argument specifies the range of source data for the graph to be added.

workbook.getWorksheet("Sheet name").getRange("Cell address")

Series

Optional. Specifies whether the data is columnar or row-oriented.

SeriesValue
Automatic identification (when omitted)ExcelScript.ChartSeriesBy.auto
ColumnExcelScript.ChartSeriesBy.columns
RowExcelScript.ChartSeriesBy.rows

The added graph can also be assigned to a variable.

The variable can then be used to change the position and size of the graph.

variable name = workbook.getWorksheet("Sheet name").addChart(
Chart type,Range of source data,Series)

For those who want to learn Office script effectively

The information on this site is now available in an easy-to-read e-book format.

Or Kindle Unlimited (unlimited reading).

You willl discover how to about basic operations.

By the end of this book, you will be equipped with the knowledge you need to use Excel Office Script to streamline your workflow.

Links

Office Scripts Articles