Possible bug with chart gradient fills

Hi,

I’ve generated an Area Stacked chart and have filled the first series with a one colour gradient. If I save the workbook as Excel 2003 then the gradient displays as expected. However, if I save the workbook as Excel 2007 (my preferred format) the series just shows up as a solid black block.

All the code and the worksheet data is identical, the only thing that changed was the save format.

Is this a bug, or do I need to set some additional features when working with the 2007 format?

An extract of the code I’m using is:

chart.NSeries[0].Area.FillFormat.SetOneColorGradient(Color.FromArgb(0, 128, 0), 0.7, GradientStyleType.FromCenter, 2);

workbook.Save(fileName, FileFormatType.Excel2007Xlsx);
or
workbook.Save(fileName, FileFormatType.Excel2003);

I’m using the evaluation version of Aspose.Cells 4.5.1.0 (the .net 2.0 dll)

Thanks.

Hi,

Thank you for considering Aspose.

This issue may be occurring due to the use of Old version of Aspose.Cells. Please try the attached latest version of Aspose.Cells. If the issue still persists, please provide us with your complete code and template file, so that we can figure it out.

Thank you & Best Regards,

Thanks for the dll, but unfortunately that didn’t resolve the issue.

At this stage I’m still evaluating Aspose.Cells so don’t have an application as such, but my test web page code is as follows:

protected void Page_Load(object sender, EventArgs e)
{
string path = Server.MapPath("~/App_Data");

Workbook workbook = new Workbook();
workbook.Open(Path.Combine(path, “Data.xlsx”));

Worksheet datasheet = workbook.Worksheets[0];
datasheet.Name = “Data”;
datasheet.IsGridlinesVisible = true;

int sheetIndex = workbook.Worksheets.Add(SheetType.Chart);
Worksheet chartsheet = workbook.Worksheets[sheetIndex];
chartsheet.Name = “Chart”;
chartsheet.IsGridlinesVisible = false;

int chartIndex = chartsheet.Charts.Add(ChartType.AreaStacked, 1, 1, 1, 1);
Chart chart = chartsheet.Charts[chartIndex];
chart.PlotArea.Border.IsVisible = true;
chart.PlotArea.Area.ForegroundColor = Color.Transparent;
chart.PageSetup.Orientation = PageOrientationType.Landscape;
chart.Legend.Position = LegendPositionType.Top;

Axis categoryAxis = chart.CategoryAxis;
categoryAxis.AxisBetweenCategories = false;
categoryAxis.CategoryType = CategoryType.AutomaticScale;
categoryAxis.MajorTickMark = TickMarkType.Outside;
categoryAxis.MajorUnitScale = TimeUnit.Days;
categoryAxis.MinorGridLines.IsVisible = false;
categoryAxis.TickLabels.NumberFormat = “General”;
categoryAxis.TickLabels.Rotation = 45;
categoryAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;
categoryAxis.TickLabelSpacing = 2;

chart.ValueAxis.MajorGridLines.IsVisible = false;
chart.ValueAxis.TickLabelPosition = TickLabelPositionType.NextToAxis;
chart.ValueAxis.MajorTickMark = TickMarkType.Outside;

chart.NSeries.Add(“Data!B2:H49”, true);
chart.NSeries.CategoryData = “Data!A2:A49”;

Color[] colorList = { Color.FromArgb(0, 128, 0),
Color.FromArgb(255, 11, 11),
Color.FromArgb(255, 206, 45),
Color.FromArgb(16, 16, 129),
Color.FromArgb(156, 156, 156),
Color.FromArgb(0, 0, 0),
Color.FromArgb(18, 205, 255),
Color.FromArgb(255, 55, 55),
Color.FromArgb(128, 255, 255),
Color.FromArgb(128, 0, 128),
Color.FromArgb(255, 255, 128),
Color.FromArgb(192, 192, 192) };

Cells cells = workbook.Worksheets[0].Cells;
for (int i = 0; i < chart.NSeries.Count; i++) {
chart.NSeries[i].Name = cells[0, i + 1].Value.ToString();
chart.NSeries[i].Area.FillFormat.SetOneColorGradient(colorList[i], 0.7, GradientStyleType.FromCenter, 2);
}

string fileName = Path.Combine(path, “Chart.xlsx”);
if (File.Exists(fileName)) {
File.Delete(fileName);
}
workbook.Save(fileName, FileFormatType.Excel2007Xlsx);
}


I’ve attached Data.xlsx.

Thanks.

Edit: I’ve also attached a zip of my Visual Studio solution.

Hi,

Thank you for providing us the detailed code and template file. We have found the issue after an initial test and we will figure it out soon.

Thank you & Best Regards,

Hi,

Thank you for considering Aspose.

Please try the attached latest fix for Aspose.Cells. We have supported export chart gradient fills with color types “GradientColorType.OneColor” and “GradientColorType.TwoColors” for Excel 2007 “.xlsx” file format.

We will look into import gradient fill from Excel 2007 “.xlsx” file format in future versions.

Thank you & Best Regards,

Thank you, the gradient is now working; your quick response is very impressive. I wish other companies were as responsive as Aspose :slight_smile:

One thing I noticed though was that the colours in the 2007 chart are a lot darker compared to the 2003 chart, and there isn’t a black out line between the different series (see attached screenshots). Is this because 2007 uses a different pallet? How can I make the necessary adjustments?

Hi,

Please try the attached version. We have fixed the issues you have mentioned in your post.

There is still a little difference between the 2003 chart and 2007 chart. That’s because the different behavior of Ms Excel 2003 and Ms Excel 2007. If you create a chart in Ms Excel 2003, the series will automatically have a border. But if you create a chart in Ms Excel 2007, the series will not have any border automatically.

Aspose.Cells follows the Ms Excel standards. So, since you have not explicitly set the series border in your code and save the chart in 2003 format the series will have border. But if you save the chart in 2007 format the series will NOT have a border.

If you need the chart in 2007 file format to display just as it is in 2003 file format, you have to set the border of the series area explicitly.

Thank you & Best Regards,

Thank you for all you help. That’s now working great!

The issues you have found earlier (filed as 6766) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Laurence.