Hi,
I am using the Add-ExcelChart command in the IMPORTEXCEL module to create excel charts. I have been able to achieve this but I would like to change one of the chart properties via Powershell that can be done manually under Format Chart Area > Chart Options > Properties.
I would like to set the property “Don’t move or size with cells”
Below is an extract from my script that defines and creates a chart:
$ChartTitle="Live vs Archived Data"
$tableName = 'LiveVsArch' # $tableName is the name to give to the Excel table hosting the data to be graphed
$LiveVsArchWorksheetName="LiveVsArch Chart"
$excel = $LiveVsArchive | Export-Excel -Path $ExportFilePath -WorksheetName $LiveVsArchWorksheetName -AutoSize -TableStyle Medium9 -TableName $tableName -PassThru -Append # In the existing workbook, create a new Worksheet and add the data as an Excel Table
$ChartDef3 = @{ # $ChartDef3 defines the size, position and data of the Live vs Archived data graph
Title = $ChartTitle
ChartType = 'ColumnStacked'
XRange = "$tableName[Versus]"
YRange = "$tableName[Total_vs]"
YAxisTitleText="Size (GB)"
YAxisTitleSize=10
YAxisTitleBold=$true
#SeriesHeader = "Size`n(GB)"
Row = 0
Column = 4
Width = 700
Height = 500
}
$chart = Add-ExcelChart @ChartDef3 -NoLegend -Worksheet $excel.$LiveVsArchWorksheetName -PassThru # Create a 2nd chart and populate it with data from the last two columns of the table
$chart.PlotArea.Fill.Color = [System.Drawing.Color]::LightYellow # Set the Plot Area colour to Light Yellow
$chart.Fill.Color = [System.Drawing.Color]::LightBlue # Set the Fill colour around the plot area to Light Blue
$chart.Series[0].Fill.Color = [System.Drawing.Color]::Green # Set the colour of the data bars to Green
$chart.XAxis.Font.Color = [System.Drawing.Color]::Blue
$chart.YAxis.Font.Color = [System.Drawing.Color]::Blue
$chart.YAxis.Title.Font.Color = [System.Drawing.Color]::Black
Is there any way to change this property programmatically?