用C++改变刻度标签方向
Contents
[
Hide
]
更改刻度标签方向
Aspose.Cells 通过使用 TickLabels.GetDirectionType() 属性提供更改图表刻度标签方向的能力。 TickLabels.GetDirectionType() 属性接受 ChartTextDirectionType 枚举值。 ChartTextDirectionType 枚举包含以下成员:
- 水平
- 垂直
- 旋转90度
- 旋转270度
- 堆叠
以下图片对比了源文件和输出文件:
源文件图像
输出文件图像
以下代码片段将刻度标签方向从Rotate90更改为水平方向
示例代码
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Directory source and output paths
U16String sourceDir(u"..\\Data\\01_SourceDirectory\\");
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create workbook and load the sample Excel file
Workbook workbook(sourceDir + u"SampleChangeTickLabelDirection.xlsx");
// Obtain the first worksheet
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Load the chart from the source worksheet
Chart chart = worksheet.GetCharts().Get(0);
// Set the category axis tick labels direction to Horizontal
chart.GetCategoryAxis().GetTickLabels().SetDirectionType(ChartTextDirectionType::Horizontal);
// Output the modified workbook to a new file
workbook.Save(outDir + u"outputChangeChartDataLableDirection.xlsx");
std::cout << "Chart tick label direction changed successfully!" << std::endl;
Aspose::Cells::Cleanup();
}
可以从以下链接下载源文件和输出文件。