Back to Devexpress

ChartObject.LoadStyle(String) Method

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-chartobject-dot-loadstyle-x28-system-dot-string-x29.md

latest3.5 KB
Original Source

ChartObject.LoadStyle(String) Method

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Loads a custom style from the specified XML file and applies it to the chart. Available only for Excel 2016 charts.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void LoadStyle(
    string fileName
)
vb
Sub LoadStyle(
    fileName As String
)

Parameters

NameTypeDescription
fileNameString

A path to the XML file that contains a chart style definition.

|

Remarks

The code sample below applies a custom style to a waterfall chart. The style.xml file contains a definition of a standard style used for histogram and funnel charts.

csharp
// Create a waterfall chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.Waterfall, worksheet["B2:C7"]);
chart.TopLeftCell = worksheet.Cells["E2"];
chart.BottomRightCell = worksheet.Cells["L17"];

// Hide the major gridlines for the value axis.
chart.PrimaryAxes[1].MajorGridlines.Visible = false;

// Specify series options.
var options = chart.Series[0].LayoutOptions.Waterfall;
// Display connector lines.
options.ShowConnectorLines = true;
// Set the third data point as the total.
options.SubtotalDataPoints.Add(2);
// Set the last data point as the total.
options.SubtotalDataPoints.Add(5);

// Load a custom style
// and apply it to the chart.
chart.LoadStyle(@"CustomStyles\style.xml");

// Add the chart title.
chart.Title.Visible = true;
chart.Title.SetValue("Income Statement");
vb
' Create a waterfall chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.Waterfall, worksheet("B2:C7"))
chart.TopLeftCell = worksheet.Cells("E2")
chart.BottomRightCell = worksheet.Cells("L17")

' Hide the major gridlines for the value axis.
chart.PrimaryAxes(1).MajorGridlines.Visible = False

' Specify series options.
Dim options As WaterfallSeriesOptions = chart.Series(0).LayoutOptions.Waterfall
' Display connector lines.
options.ShowConnectorLines = True
' Set the third data point as the total.
options.SubtotalDataPoints.Add(2)
' Set the last data point as the total.
options.SubtotalDataPoints.Add(5)

' Load a custom style
' and apply it to the chart.
chart.LoadStyle("CustomStyles\style.xml")

' Add the chart title.
chart.Title.Visible = True
chart.Title.SetValue("Income Statement")

See Also

ChartObject Interface

ChartObject Members

DevExpress.Spreadsheet.Charts Namespace