ChartObject

ワークシートの埋め込みグラフを表します。

メソッド

<表示切り替え>

Activate
BringToFront
Copy
CopyPicture
Cut
Delete
Duplicate
Select
SendToBack

プロパティ

<表示切り替え>

Application
BottomRightCell
Chart
Creator
Height
Index
Left
Locked
Name
Parent
Placement
PrintObject
ProtectChartObject
RoundedCorners
Shadow
ShapeRange
Top
TopLeftCell
Visible
Width
ZOrder

プログラム実行例

空気の構成成分の割合を円グラフにする(Excel)

CONST xlPie = 5

DIM Excel = CREATEOLEOBJ("Excel.Application")
Excel.Visible = TRUE
Excel.Workbooks.Add()

DIM array[][1] = "窒素", "78.08", "酸素", "20.95", "アルゴン", "0.93", "二酸化炭素", "0.04", "その他", "0"

WITH Excel
	FOR r = 0 TO UBound(array)
		FOR c = 0 TO UBound(array[0])
			.Cells(r+1, c+1) = array[r][c]
		NEXT
	NEXT
	DIM ChartObjects = .ActiveSheet.ChartObjects
	DIM ChartObject = ChartObjects.Add(.Range("C1").Left, .Range("C1").Top, .Range("C1:I22").Width, .Range("C1:I22").Height)
	DIM Chart = ChartObject.Chart
	WITH Chart
		.ChartType = xlPie
		.HasLegend = FALSE
		.SetSourceData(Excel.Range("A1").CurrentRegion)
		.ApplyLayout(4)
	ENDWITH
ENDWITH

//////////////////////////////////////////////////
// 【引数】
//   配列 : 上限値を求める配列 
// 【戻値】
//   配列の上限値 
//////////////////////////////////////////////////
FUNCTION UBound(array[])
	RESULT = RESIZE(array)
FEND
    (3) (4) (5) (10,11) (12)
  1. Excel.Worksheet.ChartObjects(15)
  2. Excel.ChartObjects.Add(16)
  3. Excel.ChartObjects.Chart(16)
  4. (16,21)
  5. Excel.Range.Left(16)
  6. Excel.Range.Top(16)
  7. Excel.Range.Width(16)
  8. Excel.Range.Height(16)
  9. (16)
  10. Excel.ChartObject.ChartType(19)
  11. Excel.ChartObject.HasLegend(20)
  12. Excel.ChartObject.SetSourceData(21)
  13. (21)
  14. Excel.ChartObject.ApplyLayout(22)

参考文献

  1. ChartObject オブジェクト (Excel) | Microsoft Docs