PowerPoint 文件中的图表轴

Chart axes in PowerPoint file

我正在使用 GemBox.Presentation(连同 GemBox.Spreadsheet)在 PPTX 文件中创建图表(ComboChart 类型)。我正在使用 PowerPoint Chart example and added parts of the Excel Combo Chart 示例中的代码。

这是我目前拥有的:

var presentation = new PresentationDocument();
var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);
var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Combo, 25, 25, 300, 500);
var comboChart = (ComboChart)chart.ExcelChart;
var worksheet = comboChart.Worksheet;

worksheet.Cells["A1"].Value = "Name";
worksheet.Cells["A2"].Value = "John Doe";
worksheet.Cells["A3"].Value = "Fred Nurk";

worksheet.Cells["B1"].Value = "Salary";
worksheet.Cells["B2"].Value = 4023;
worksheet.Cells["B3"].Value = 3263;

worksheet.Cells["C1"].Value = "Max";
worksheet.Cells["C2"].Value = 4500;
worksheet.Cells["C3"].Value = 4300;

worksheet.Cells["D1"].Value = "Min";
worksheet.Cells["D2"].Value = 3000;
worksheet.Cells["D3"].Value = 2800;

comboChart.CategoryLabelsReference = "A2:A3";

var salaryChart = comboChart.Add(GemBox.Spreadsheet.Charts.ChartType.Column);
salaryChart.Series.Add("=B1", "B2:B3");

var minMaxChart = comboChart.Add(GemBox.Spreadsheet.Charts.ChartType.Line);
minMaxChart.Series.Add("=C1", "C2:C3");
minMaxChart.Series.Add("=D1", "D2:D3");

presentation.Save("output.pptx");

这就是我得到的:

现在我的问题是我找不到任何方法来访问和格式化类别轴和垂直轴。

我尝试使用 chartcomboChartsalaryChartminMaxChart objects,但其中 none 有任何轴属性!?

比方说,我怎样才能设置轴标题?

要设置组合图表的坐标轴,您需要使用其包含图表之一的坐标轴,因此 salaryChartminMaxChart

现在您看不到它们的任何轴属性的原因是它们是基本类型 (ExcelChart)。您需要将它们转换为派生类型,如下所示:

var salaryChart = (ColumnChart)comboChart.Add(GemBox.Spreadsheet.Charts.ChartType.Column);
salaryChart.Series.Add("=B1", "B2:B3");

salaryChart.Axes.Horizontal.Title.Text = "My Categories";
salaryChart.Axes.Vertical.Title.Text = "My Values";