Apply horizontal alignment formatting to Excel worksheet cells in Java

I experiance weird behavior when I set horizontalalignment to a cell:


This code:
for(int c = 0; c < output.table.columnnames.length ; c ++){
Cell headercell = cells.get(4,c+1);
headercell.setValue(output.table.columnnames[c]);
Style headerstyle = headercell.getStyle();
headerstyle.getFont().setBold(true);
headerstyle.setRotationAngle(-90);
headerstyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
headercell.setStyle(headerstyle);
}

Causes the first cell to behave weird. When I remove the horizontal alignment setting things are as expected.

See the attached file for an example of the output.

Is this a bug?

Hi,

Please download and try our latest version: Aspose.Cells for Java v7.2.1.8


If you still find the issue, give us your template file(s). We will check your issue soon.

Thank you.

Hi,


I have tested your mentioned issue with our latest fix as suggested to you by Amjad. Please download and use it with the following lines of code:

Workbook workbook = new Workbook(“D:\Test.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(0);

Cells cells = worksheet.getCells();
for(int c = 0; c < 7; c++)
{
Cell headercell = cells.get(1, c + 1);
Style headerstyle = headercell.getStyle();
headerstyle.getFont().setBold(true);
headerstyle.setRotationAngle(-90);
headerstyle.setHorizontalAlignment(TextAlignmentType.CENTER);
headercell.setStyle(headerstyle);
}
workbook.save("D://Output.xlsx");

I have attached the source and output excel files for your reference as well. I hope this is what you want to achieve. Please let us know if we can be of additional help to you.