如何使用 EPPlus 将 excel 条形图上的数据标签更改为 inside base?
How do I change a data label on an excel bar chart to inside base using EPPlus?
我有一个正在使用 EPPlus 创建的 ExcelBarChart
。
我正在尝试将数据标签的位置更改为 Inside Base,但是当我查看 ExcelBarChart
对象内部时,我看到一个 ExcelChartDataLabel
属性,并且在里面一个名为 eLabelPosition
.
的 属性
eLabelPosition
受保护但无法访问。
使用 EPPlus 设置数据标签位置的正确方法是什么?
相关代码见下方:
var chart = (ExcelBarChart)chartWorksheet.Drawings.AddChart("changesVisualized", eChartType.ColumnClustered);
chart.SetSize(1000, 500);
chart.SetPosition(0,0);
chart.Title.Text = row.Name + "Volume " + date1.ToString("MM/dd/yyyy") + " - " + date2.ToString("MM/dd/yyyy");
chart.DataLabel.ShowValue = true;
var thisYearSeries = (ExcelChartSerie)(chart.Series.Add(worksheet.Cells["B4,D4,F4,H4,J4"], worksheet.Cells["B3,D3,F3,H3,J3"]));
thisYearSeries.Header = "This Year's Volume";
var lastYearSeries = (ExcelChartSerie)(chart.Series.Add(chartWorksheet.Cells["A1,B1,C1,D1,E1"], worksheet.Cells["B3,D3,F3,H3,J3"]));
lastYearSeries.Header = "Last Year's Volume";
你可以这样做:
var barChart = worksheet.Drawings.AddChart("Chart1", eChartType.ColumnClustered);
barChart.SetPosition(data.Count + 1, 0, 0, 0);
barChart.Title.Text = "Test Chart";
barChart.Title.Font.Bold = true;
barChart.Title.Font.Size = 12;
var serie = barChart.Series.Add(worksheet.Cells[2, 2, data.Count + 1, 2], worksheet.Cells[2, 1, data.Count + 1, 1]);
var barSeries = (ExcelBarChartSerie)serie;
barSeries.DataLabel.Font.Bold = true;
barSeries.DataLabel.ShowValue = true;
barSeries.DataLabel.ShowPercent = true;
barSeries.DataLabel.ShowLeaderLines = true;
barSeries.DataLabel.Separator = ";";
barSeries.DataLabel.Position = eLabelPosition.InBase;
改编自我这里的例子:
How do I modify a chart series using EPPLus?
我有一个正在使用 EPPlus 创建的 ExcelBarChart
。
我正在尝试将数据标签的位置更改为 Inside Base,但是当我查看 ExcelBarChart
对象内部时,我看到一个 ExcelChartDataLabel
属性,并且在里面一个名为 eLabelPosition
.
eLabelPosition
受保护但无法访问。
使用 EPPlus 设置数据标签位置的正确方法是什么?
相关代码见下方:
var chart = (ExcelBarChart)chartWorksheet.Drawings.AddChart("changesVisualized", eChartType.ColumnClustered);
chart.SetSize(1000, 500);
chart.SetPosition(0,0);
chart.Title.Text = row.Name + "Volume " + date1.ToString("MM/dd/yyyy") + " - " + date2.ToString("MM/dd/yyyy");
chart.DataLabel.ShowValue = true;
var thisYearSeries = (ExcelChartSerie)(chart.Series.Add(worksheet.Cells["B4,D4,F4,H4,J4"], worksheet.Cells["B3,D3,F3,H3,J3"]));
thisYearSeries.Header = "This Year's Volume";
var lastYearSeries = (ExcelChartSerie)(chart.Series.Add(chartWorksheet.Cells["A1,B1,C1,D1,E1"], worksheet.Cells["B3,D3,F3,H3,J3"]));
lastYearSeries.Header = "Last Year's Volume";
你可以这样做:
var barChart = worksheet.Drawings.AddChart("Chart1", eChartType.ColumnClustered);
barChart.SetPosition(data.Count + 1, 0, 0, 0);
barChart.Title.Text = "Test Chart";
barChart.Title.Font.Bold = true;
barChart.Title.Font.Size = 12;
var serie = barChart.Series.Add(worksheet.Cells[2, 2, data.Count + 1, 2], worksheet.Cells[2, 1, data.Count + 1, 1]);
var barSeries = (ExcelBarChartSerie)serie;
barSeries.DataLabel.Font.Bold = true;
barSeries.DataLabel.ShowValue = true;
barSeries.DataLabel.ShowPercent = true;
barSeries.DataLabel.ShowLeaderLines = true;
barSeries.DataLabel.Separator = ";";
barSeries.DataLabel.Position = eLabelPosition.InBase;
改编自我这里的例子:
How do I modify a chart series using EPPLus?