Aspose.Cells 绘制Excel三维簇状柱形图
- 数据
- 创建工作簿
- 创建图表
- 一般设置
- 保存
数据
创建工作簿
var book = new Workbook();
book.Worksheets[0].Name = "DataSheet";
var dataSheet = book.Worksheets["DataSheet"];
创建图表
var chartIndex = dataSheet.Charts.Add(Aspose.Cells.Charts.ChartType.Column3DClustered,1, 5, 21, 15);
Aspose.Cells.Charts.Chart chart = dataSheet.Charts[chartIndex];
chart.NSeries.Add("DataSheet!B1:B11", true);
chart.NSeries.CategoryData = "A2:A11";
var series = chart.NSeries[0];
series.Name = "=B1";
series.Values = "=B2:B11";
// 图例
chart.ShowLegend = false;
一般设置
// 图表位置
chart.ChartObject.X = 350;
chart.ChartObject.Y = 10;
// 基底面
chart.Floor.Border.Color = Color.White;
// 绘图区
chart.PlotArea.Area.BackgroundColor = Color.White;
chart.ChartArea.Area.BackgroundColor = Color.White;
chart.PlotArea.Area.ForegroundColor = Color.White;
chart.ChartArea.Area.ForegroundColor = Color.White;
chart.PlotArea.Border.IsVisible = false;
chart.PlotArea.IsAutomaticSize = true;
// 数据表
chart.ShowDataTable = true;
chart.ChartDataTable.ShowLegendKey = true;
chart.ChartDataTable.Font.Name = "Times New Roman";
chart.ChartDataTable.Font.Size = 9;
chart.ChartDataTable.Border.Color = Color.FromArgb(MajorAxisColor);
// 柱颜色
chart.NSeries[0].Area.ForegroundColor = Color.FromArgb(SeriesColor);
// Series轴
chart.SeriesAxis.IsVisible = false;
保存
book.Save(System.IO.Path.Combine(xlsxPath, name + ".xlsx"));
本文链接:https://my.lmcjl.com/post/14350.html
展开阅读全文
4 评论