Sets all data related properties of an existing chart or chartsheet.
#Include <ExcelChart.au3>
_XLChart_ChartDataSet($oChart, $sXValueRange, $vDataRange, $vDataName)
Parameters
$oChart | Chart object as returned by a preceding call to _XLChart_ChartCreate |
$sXValueRange | Category (X) axis label range always a single range (eg. "=Sheet1!R2C1:R6C1") |
$vDataRange | The values range. Either a single range or an one-dimensional one based array |
$vDataName | Header name of the range. Either a single range or an one-dimensional one based array |
Return Value
Success: 1
Remarks
None.
Related
Example
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include-once
#include <ExcelChart.au3>
; *****************************************************************************
; Create example environment
; *****************************************************************************
Global $aExcel = _XLChart_Example(True, 0, -1, -1, -1)
If @error = 2 Then Exit MsgBox(16, "Excel Chart Example Script", "The installed Excel version is not supported by this UDF!" & @CRLF & "Version must be >= 12 (Excel 2007).")
If @error <> 0 Then Exit MsgBox(16, "Excel Chart Example Script", "Error " & @error & " returned by _XLChart_Example on line " & @ScriptLineNumber)
; *****************************************************************************
; Example 1
; Set a new value range, data range and data name for Chart 1:
; *****************************************************************************
; Create new data
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Creating new data")
$aExcel[0] .Activesheet.Cells(1, 5).Value = "Date"
$aExcel[0] .Activesheet.Cells(2, 5).Value = "'01/2012"
$aExcel[0] .Activesheet.Cells(3, 5).Value = "'02/2012"
$aExcel[0] .Activesheet.Cells(4, 5).Value = "'03/2012"
$aExcel[0] .Activesheet.Cells(5, 5).Value = "'04/2012"
$aExcel[0] .Activesheet.Cells(6, 5).Value = "'05/2012"
$aExcel[0] .ActiveSheet.Columns(5).AutoFit
$aExcel[0] .Activesheet.Cells(1, 6).Value = "Sales Store A"
$aExcel[0] .Activesheet.Cells(2, 6).Value = "100"
$aExcel[0] .Activesheet.Cells(3, 6).Value = "235"
$aExcel[0] .Activesheet.Cells(4, 6).Value = "105"
$aExcel[0] .Activesheet.Cells(5, 6).Value = "205"
$aExcel[0] .Activesheet.Cells(6, 6).Value = "340"
$aExcel[0] .ActiveSheet.Columns(6).AutoFit
$aExcel[0] .Activesheet.Cells(1, 7).Value = "Sales Store B"
$aExcel[0] .Activesheet.Cells(2, 7).Value = "180"
$aExcel[0] .Activesheet.Cells(3, 7).Value = "203"
$aExcel[0] .Activesheet.Cells(4, 7).Value = "140"
$aExcel[0] .Activesheet.Cells(5, 7).Value = "320"
$aExcel[0] .Activesheet.Cells(6, 7).Value = "228"
$aExcel[0] .ActiveSheet.Columns(7).AutoFit
Global $XValueRange = "=_XLChart_Example!R2C5:R6C5"
Global $asXLC_DataRange[3] = [2, "=_XLChart_Example!R2C6:R6C6", "=_XLChart_Example!R2C7:R6C7"]
Global $asXLC_DataName[3] = [2, "=_XLChart_Example!F1", "=_XLChart_Example!G1"]
; Changing chart
MsgBox(64, "Excel Chart Example Script", "Now changing chart 1 ..." & @CRLF & "Set new value range, data range and data name")
_XLChart_ChartDataSet($aExcel[1], $XValueRange, $asXLC_DataRange, $asXLC_DataName)
If @error Then MsgBox(64, "Excel Chart Example Script", "Error " & @error & " returned by function '_XLChart_ChartDataSet' on line " & @ScriptLineNumber)