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

Free Support Forum - aspose.com

REg : Autofit Column with for Aspose 8.3.2 versionj

Hi Team,

We are using Aspose 8.3.2 jar in our application. While downloading our reports in excel sheet some of the column with are not aligned automatically. For example suppose the number of digit is more than 7 in the particular cell then it shows the exponential value.

We are facing the issue only in environments but the same is working fine in our local servers.

We are using the following configuration in our XMLs


Please clarify the below;

1.Why the same issue happen only in environment and not happen in local server
2. Suggest us in case of any common auto fit cell width

Thanks in advance.

Hi Karthikeyan,

Thank you for contacting Aspose support.

It would be appropriate that you should share the sample spreadsheet exhibiting the said behaviour as well as 2 PDF files generated on different machines. Please note, we require the PDF files to review how Aspose.Cells API has used and embedded fonts in 2 different environments. Please note, the width of the columns (in case of autoFitColumn(s) operation) directly depends on the size of the contents in a particular cell as well as the font used to format the cell contents. Based on this fact, I suspect that you probably have different set of fonts available on the 2 machines whereas on the problematic server, you are probably missing the font that has been used to format the cell contents. In such cases, Aspose.Cells APIs tries to substitute the required font (used in the spreadsheet) with the one available, as a result the content appearance and size changes.

Moreover, it is also possible that the said issue is caused due to some bug in your current version of the API. You can rule this out by trying the latest version of the Aspose.Cells for Java 16.11.7 (attached) on problematic machine. In case you still do not get the desired results we will require the above requested artifacts along with executable code to replicate the case on our side. Please note, we do not require you to post your original application, however, we do require the exact sequence of statements that we could execute on our side in order to replicate the said issue. Please be kind enough to make the code executable so that we do not need to change anything in order to observe the same results as of yours.

Hi Team,

Thanks for the details.

As mentioned we have attached the sample java code and the resultant excel created from our local server and sub prod environment and also their respective pdf files.

Issue details:

In the sample code, we have passed the excel which is having issue as input and tried to auto fit it and saved it. TestFileBefore1481971124205.xls --> TEST sheet
In addition to this sheet we have added a additional sheet (Sheet1) where we had set the value for one particular cell alone.

While running the sample code in local server we had got the following result sheet ExportExcel1482037911445.xls .

In this resultant excel, in both the sheets the column width had been auto fit to its contents.

But the same when exceuted on sub prod enviroment, we got the following resultant excel. AfterAutoFit1482043026263.xls

In this resultant excel , only the Sheet1 columns had been auto fit to the contents but the TEST sheet columns had not been auto fit to its contents and we are getting exponential values and ‘##’ values in excel.

The resulted values has been highlighted in the attached excel sheets.

Note : We had changed the location and report name details in sample code when it is execeuted on sub prod environment.

Server details : WebLogic Server Version:

Java version "1.6.0_21"

Same version used in both local and sub prod environments.

Please help us in resolving this issue and let us know if any further details are required.

Thanks in advance.

Hi Karthikeyan,

Thank you for sharing the samples and code snippet. I have evaluated the presented scenario while using the latest version of Aspose.Cells for Java 16.12.0 & your current revision 8.3.2. I am afraid, I am not able to replicate the said issue with any of the aforementioned releases. That said, I think the problem cause is the availability of the required fonts in your problematic server. I was not able to confirm this because the PDF shared by you are not directly generated by Aspose.Cells APIs. If you can, please execute the complete process (as shared in Aspose_testFormat.txt) and save the final result in PDF as well as XLS. If you review the PDF’s document properties for the embedded fonts (Fonts tab) it should list 2 font families, that are, Arial & Verdana. If you cannot find these font names under the Font tab of the document properties, that mean, you do not have the required fonts available on the machine.

Please not, in case you are missing any of the required fonts in your problematic server, Aspose.Cells will try to substitute the font with any available one. As a consequence, the Worksheet.autoFitColumns operation will not be able to correctly calculate the width of the cells to fit all contents so you will end up with string of # characters for numeric values.

Moving forward, please check the list of the available fonts in the two environments as I believe there could be some differences. Moreover, please try the scenario again on the problematic machine by placing the TTF files of Arial & Verdana in any directory, and explicitly tell the Aspose.Cells APIs where you have placed the fonts by using the CellsHelper.setFontDir method (path passed to setFontDir method should contain the TTF files at root). please note, this method has been marked depreciated with most recent releases of the API but you should be able to use it without any problem against Aspose.Cells for Java 8.3.2. In case the problem persists, please share the PDF files directly generated with Aspose.Cells for review.