We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Chart Style is not working

Hi,

I creating a excel sheet with chart and it is working fine but chart style is not working… Always it shows the default chart style… Below is my code :

AsWorkBook = new Workbook();
int sheetIndex = AsWorkBook.Worksheets.Add();
sheet = AsWorkBook.Worksheets[sheetIndex];

int chartIndex = sheet.Charts.Add(ChartType.LineStackedWithDataMarkers, 5, 0, 15, 5);

Chart chart = sheet.Charts[chartIndex];
chart.Style = 46;
chart.NSeries.Add(“Data!B12:D12”, true);
chart.PlotArea.Border.IsVisible = true;
chart.CategoryAxis.MajorGridLines.IsVisible = false;
chart.NSeries.IsColorVaried = true;
chart.GapWidth = 20;
chart.PlotArea.BackgroundMode = BackgroundMode.Automatic;
chart.Legend.Position = LegendPositionType.Bottom;

sheet.AutoFitColumns();
sheet.Name = “Chart”;

Hi,


I have tested and created a sample chart to set its style, it works fine. I am using v7.1.1.5 : Aspose.Cells for .NET v7.1.1.5
Here is my complete runnable sample code, please find output file (.Net Chart - Urgent pls) for reference:

Sample code:
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Get First Worksheet of the Workbook
Worksheet ws = workbook.Worksheets[0];
//Set Worksheet Type
ws.Type = SheetType.Chart;
//Add new Data Sheet
Worksheet data = workbook.Worksheets.Add(“Data”);
Cells cells = data.Cells;
cells[“A1”].PutValue(“Aspose.Cells”);
cells[“A2”].PutValue(“Aspose.Words”);
cells[“A3”].PutValue(“Aspose.PDF”);
cells[“B1”].PutValue(35);
cells[“B2”].PutValue(50);
cells[“B3”].PutValue(15);

ChartCollection charts = ws.Charts;

int index = charts.Add(ChartType.Pie, 5, 5, 15, 10);
Chart chart = charts[index];
chart.NSeries.Add(“Data!B1:B3”, true);
chart.NSeries.CategoryData = “Data!A1:A3”;
chart.Style = 46;

workbook.Save(“e:\test2\outstyle_testchart1.xlsx”);

If you still find the issue with latest fix, kindly create a runnable code or give us your template Excel file, so that we could evaluate your code accordingly.

Thank you.