This quick tutorial contains information on how to rotate a cell in Excel using Java. It provides configuration details and the sequence of steps required to set text orientation in Excel using Java. You can not only change the cell text orientation but set other style properties also before saving the output file into any of the desired formats like XLSX, XLS, ODF, etc.
Steps for Rotating Cells in Excel using Java
- Configure your project to add Aspose.Cells from the Maven repository to rotate cell text
- Create or load a Workbook and set some text in the target cell of a particular worksheet
- Get the style of the target cell
- Set the rotation angle using setRotationAngle() method
- Set the style of the target cell after setting the rotation angle
These steps describe how to rotate Excel cells using Java by providing the required project configuration details and the program flow to achieve the requirement. It also contains the necessary classes and the methods used to rotate the cell. Note that it is not necessary to create a new file and add text to a cell but you can load an existing workbook and rotate text in any of the cells in it.
Code to Rotate a Cell in Excel using Java
This code snippet describes how to tilt cells in Excel using Java. Here the style of the cell is obtained and then its rotation angle is set before setting this style back to the original cell. You can change other properties also like setting the foreground/background color using 32bit ARGB value or the color directly, setting borders, font, and indent level to name a very few.
In this article, we have learned to set the orientation of contents in a cell using Java however if you want to learn the process to adjust column width, refer to the article on how to adjust column width in Excel using Java.