Free Support Forum - aspose.com

Text alignment in a row

Am using Aspose.Cells for java and facing an issue.

Please look at the screen shot attached. The data in first row last col is coming out. My requirement is all the headers present in first row should be visible. and data should get aligned to that.

Please let me know how to do this.

Hi,


I guess you need to use Auto Fit Columns. Below is a link to technical article on this subject. Please feel free to write back again.
http://www.aspose.com/documentation/java-components/aspose.cells-for-java/autofit-rows-columns.html

I tried with autofitRow and autoFitColumn also. Nothing seems to be working.

Hi again,


I tried my below source code with latest version of Aspose.Cells JAVA v2.5.4.5[attached] and it is working for me. Please test the latest jar for your requirement and let us know of your feedback.

JAVA

Workbook book = new Workbook();
Worksheet sheet = book.getWorksheets().getSheet(0);
Cells cells = sheet.getCells();
cells.getCell(“A1”).setValue(“Its a Header”);
cells.getCell(“A2”).setValue(“Its a value”);
sheet.autoFitColumn(0);
book.save(“C:\temp\out.xlsx”,FileFormatType.XLSX);

Able to do it. was using Styleflag and that was causing issue in setting this.Thank you.