Ändra Tick Label riktning med C++
Ändra riktning för ticketiketter
Aspose.Cells ger dig möjlighet att ändra riktningen på diagrammets ticketiketter genom att använda egenskapen TickLabels.GetDirectionType(). Egenskapen TickLabels.GetDirectionType() accepterar värdet för ChartTextDirectionType ENUMERATION. ENUMERATION ChartTextDirectionType innehåller följande medlemmar:
- Horisontell
- Vertikal
- Rotera 90
- Rotera 270
- Staplad
Följande bild jämför källfilen och utdatafilen:
Källfilens bild
Utdatasfilens bild
Följande kodsnutt ändrar ticketikettens riktning från Rotera 90 till Horisontell.
Exempelkod
#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();
}
Käll- och utdatafilerna kan laddas ned från följande länkar.