Reputation: 2255
I am using Java Aspose library. And for particular Range of Cells in Excel Document I need to apply horizontal left alignment.
This is the way how I receive Range:
Range range = sheet.cells.createRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1)
That is the way I chose for setting horizontal aligment:
Style style = sheet.workbook.createStyle()
style.horizontalAlignment = 1
StyleFlag flg = new StyleFlag()
flg.horizontalAlignment = true
range.applyStyle(style, flg)
I suppose this is not the right way.
Upvotes: 0
Views: 700
Reputation: 1931
See the following sample code segment using Aspose.Cells APIs that works fine as I tested: e.g Sample code:
Range range = sheet.getCells().createRange(startRow, startColumn, endRow - startRow + 1, endColumn - startColumn + 1);
Style style = workbook.createStyle();
style.setHorizontalAlignment(TextAlignmentType.LEFT);
StyleFlag flg = new StyleFlag();
flg.setHorizontalAlignment(true);
range.applyStyle(style, flg);
PS. I am working as Support developer/ Evangelist at Aspose.
Upvotes: 2