使用Node.js通过C++更改刻度标签方向
Contents
[
Hide
]
更改刻度标签方向
Aspose.Cells 通过使用 TickLabels.getDirectionType() 属性提供更改图表刻度标签方向的能力。 TickLabels.getDirectionType() 属性接受 ChartTextDirectionType 枚举值。 ChartTextDirectionType 枚举包含以下成员:
- 水平
- 垂直
- 旋转90度
- 旋转270度
- 堆叠
以下图像比较了源文件和输出文件
源文件图像
输出文件图像
以下代码片段将刻度标签方向从Rotate90更改为水平方向
示例代码
const path = require("path");
const AsposeCells = require("aspose.cells.node");
// The path to the documents directory.
const sourceDir = path.join(__dirname, "data");
const outputDir = path.join(__dirname, "output");
const filePath = path.join(sourceDir, "SampleChangeTickLabelDirection.xlsx");
// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);
const worksheet = workbook.getWorksheets().get(0);
// Load the chart from source worksheet
const chart = worksheet.getCharts().get(0);
chart.getCategoryAxis().getTickLabels().setDirectionType(AsposeCells.ChartTextDirectionType.Horizontal);
// Output the file
workbook.save(path.join(outputDir, "outputChangeChartDataLableDirection.xlsx"));
可以从以下链接下载源文件和输出文件。