我遇到了 EPPlus (4.0.1) 的问题。我的条形图是水平绘制的,但我希望它是垂直的。我正在尝试更改“chart.Direction”属性,但由于它是只读的,因此出现错误。我也看不到在构造函数中为我的“ExcelBarChart”变量设置变量的方法。抱歉,如果这是一个基本问题,我正在阅读文档但无法弄清楚。据我所知,chart.Direction 甚至可能不是正确的属性。我正在用 C# 编程。提前感谢您的任何答案。
OfficeOpenXml.Drawing.Chart.ExcelBarChart chart = (OfficeOpenXml.Drawing.Chart.ExcelBarChart)ws.Drawings.AddChart("barChart", OfficeOpenXml.Drawing.Chart.eChartType.BarClustered);
chart.SetSize(widthPx, heightPx);
chart.SetPosition(startTopPx, startLeftPx);
chart.Title.Text = "Clustered Bar Graph Report";
chart.Direction = eDirection.Column; // error: Property or indexer 'OfficeOpenXml.Drawing.Chart.ExcelBarChart.Direction' cannot be assigned to -- it is read only
ws.Cells["A1"].LoadFromDataTable(data, true); // load dataTable into Cells
int fromRow = 2;
int toRow = 2;
int fromCol = 2;
int toCol = 5;
int xRow = 2;
int xCol = 1;
chart.Series.Add(ExcelRange.GetAddress(fromRow, fromCol, toRow, toCol),
ExcelRange.GetAddress(xRow, xCol));