We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text alignment in workbook cell using Aspose.Cells for Java

Is there any setting to allow spacing the text withing the cells by considering the negative value brackets?

In other words. As you can see by the attached screen shot, at the moment it is displaying all text aligned to the far right of the cell.

The "correct" way would be to have all the numeric values aligned underneath each other.

And the negative brackets extending after those values.

(Bottom image)

Instead of all cell's last charater to be right aligned underneath each other

(Top image)


Please check the topic:

Aspose.Cells does supports all the MS Excel’s Alignment settings regarding Horizontal and Vertical text alignment settings. You may use the relevant APIs accordingly.

If you still find any issue regarding applying alignment settings, give us you sample code and output Excel file here, we will check your issue soon.

Thank you.

In my Application
When I using the cell.getStyle().setHi…Alignment(TextAlignmentType.CENTER)

Exported excel the cell value can’t alignment center.


We are sorry, the above link was an older link and invalid now.

Please refer to this updated link. It will help you know how to set the alignment of the cell.
Configuring Alignment Settings

Below is a code to set the horizontal alignment to center

//Instantiating a Workbook object
Workbook workbook = new Workbook();

//Accessing the added worksheet in the Excel file
int sheetIndex = workbook.getWorksheets().add();
Worksheet worksheet = workbook.getWorksheets().get(sheetIndex);
Cells cells = worksheet.getCells();

//Adding the current system date to “A1” cell
Cell cell = cells.get(“A1”);
Style style = cell.getStyle();

//Adding some value to the “A1” cell
cell.setValue(“Visit Aspose!”);

//Setting the horizontal alignment of the text in the “A1” cell

//Saved style

//Saving the modified Excel file in default format