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

Free Support Forum - aspose.com

autoFitColumns() doesn't work well with line breaks

Dear Aspose


I’ve just upgraded aspose-cells from 8.8.3 to 17.4.0, and have found that the autoFitColumns has broke when the cells contain text with line breaks. The following will not auto fit very well:

String s = “line1 \r\n line2”;

We see that the column will fit to the size of the entire text in one line, but do the line breaks on the final sheet. This results in some very wide columns with double width.

Can you please fix this?

Hi,


Thanks for providing us details.

I have tested your scenario/case a bit. I used the following sample code for it. I found that the AutoFit Columns operation does not fit the second column (which has wrapped text) correctly. When I auto-fit the second column in MS Excel manually, it sets the column’s width (minimizes it) currently.
e.g
Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
cells.get(“A1”).putValue(“Hello World!”);
String s = “line1 \r\n line2”;
cells.get(“B1”).putValue(s);
Style style = cells.get(“B1”).getStyle();
style.setTextWrapped(true);
cells.get(“B1”).setStyle(style);
worksheet.autoFitColumns();
workbook.save(“f:\files\out1.xlsx”);


I have attached the output file for your reference. Could you check and confirm if this is the issue, you are talking about or something else? After your confirmation, I will log a ticket for it accordingly so nothing should be missed. If you are talking about some other issue, kindly do paste your sample code with template file(s), we will check it soon.

Thank you.

Hi,


I can confirm this. It’s almost the same way I do it. I supply four parameters for the autFitColumns method, but the rest is a copy.

You code also proves my point if you switch back to Aspose 8.8.3. This version works by minimizing the column width as expected.

Hi,


Thanks for the confirmation.
As I observed the issue as you mentioned by using the following sample code.The Worksheet.autoFitColumns() does not work well with the cells having line breaks. I also tested it with v8.8.3, it works as expected:
e.g
Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
cells.get(“A1”).putValue(“Hello World!”);
String s = “line1 \r\n line2”;
cells.get(“B1”).putValue(s);

Style style = cells.get(“B1”).getStyle();
style.setTextWrapped(true);
cells.get(“B1”).setStyle(style);

worksheet.autoFitColumns();

workbook.save(“f:\files\out1.xlsx”);

I have logged a ticket with an id “CELLSJAVA-42271” for your issue. We will look into it soon.

Once we have an update on it, we will let you know here.

Thank you.

Thanks. I’ll look forward to hearing from you.

Hi,


This is to inform you that we have fixed your issue now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

Once the fix is available for public use, we will share the Download link here.

Thank you.
Hi,

Thanks for using Aspose.Cells.

Please download and try the following latest fix: Aspose.Cells for Java v17.4.5 and let us know your feedback.

Can you provide the version using Maven? 17.4.5 isn’t available using http://maven.aspose.com/artifactory/simple/ext-release-local/com/aspose/aspose-cells/

Hi,


Thanks for your posting and using Aspose.Cells.

We are afraid, whenever the last digit in the version number is non-zero, it is considered as hot fix and if it is zero, it is considered as release, only releases are available via Maven.

Please wait for our next release i.e. 17.5.0, which will include this fix as well and it will also be available via Maven.

FYI: The next release will be delivered somewhere between 15-25th May, 2017.

Hi Shakeel Faiz


The fix works well. The column width is now as expected. Thank you very much.

Hi,


Thanks for your feedback.

Good to know that your issue is sorted out by the new fix. Feel free to contact us any time if you have further comments or questions, we will be happy to assist you soon.

Thank you.

The issues you have found earlier (filed as CELLSJAVA-42271) have been fixed in Aspose.Cells for Java 17.5.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.