Create Union Range

Create Union Range

Aspose.Cells provides the ability to create Union Range by using the WorksheetCollection.CreateUnionRange method. The WorksheetCollection.CreateUnionRange method accepts two parameters, the address to create the union range and the index of the worksheet. The WorksheetCollection.CreateUnionRange method returns a UnionRange object.

The following code snippet demonstrates creating a Union Range by using the WorksheetCollection.CreateUnionRange method. The output file generated by the code is attached for reference.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
//Source directory
String sourceDir = Utils.Get_SourceDirectory();
//Output directory
String outputDir = Utils.Get_OutputDirectory();
// Instantiating a Workbook object
Workbook workbook = new Workbook(sourceDir + "SampleChangeTickLabelDirection.xlsx");
Worksheet worksheet = workbook.getWorksheets().get(0);
// Load the chart from source worksheet
Chart chart = worksheet.getCharts().get(0);
chart.getCategoryAxis().getTickLabels().setDirectionType(ChartTextDirectionType.HORIZONTAL);
// Output the file
workbook.save(outputDir + "outputChangeTickLabelDirection.xlsx");