If I run above code , I am not getting any exception but if I tried to open excel sheet getting popup like "Excel found unreadable content in A.xlsx. Do you want to recover the content of this workbook?" If I click Yes, then cell having that data but data length is 32768 not 33000.
Kindly find the attached A.xlsx file.
Please guide to get proper data without any excel opening issue.
Thanks for providing us template file and sample code.
After an initial test, I observed the issue as you mentioned by using your sample code with a simple template file. I found when I opened the output file into MS Excel, it prompts the “Excel found unreadable content…” error. e.g Sample code:
LoadOptions options = new LoadOptions();
options.setCheckExcelRestriction(false);
Workbook excel = new Workbook(“Book1.xlsx”, options);
I got same issue in .NET: We have provided a new option:
Workbook.Settings.CheckExcelRestriction
When you set this property as false, we will not give exception for long string value that is longer than 32K and you can save it completely to CSV file later. However, if you save the workbook as Excel files, such as XLS, XLSX with such kind of invalid cell value, unexpected problem may occur for the created Excel file.
But in my case, I am opening existing file and populating data and saving it as XLSX, XLS, PDF etc. format.
So please make sure that fix will work for diff file types.
I suspect it is not an issue with the product but expected behavior. I used my above code segment after adding a line of code at the end to save as the file to CSV file format.
e.g
Sample code:
…
excel.save(“out2.csv”, SaveFormat.CSV);
when I open the CSV file, it opens fine into MS Excel without any error.
Well, as MS Excel does not allow a string more than 32k to be inserted into a cell for its native XLS/ XLSX, you may confirm this in Ms Excel by manually trying to accomplish the task, so if we do input a string more than 32K into a cell, MS Excel will invalidate it due to the corrupted or invalid data into a cell, you cannot save such a file in MS Excel.
Anyways, our concerned developer will further evaluate your issue as we have already logged a ticket with an id “CELLSJAVA-40986” into our database.
Once we have any update on it, we will let you know here.
You are right. There seems to me an issue with the product as when I used my code segment to open your template file and re-saved it (after making the Excel restriction (for the 32K string) to false), I still got the error when I opened the output file into MS Excel. We will look into it soon.
I am trying to say, if I manually open one excel file and try to save string which have length more than 32676, then it splitting data into two part, A1 cell have data from 0 to 32675 and B1 cell have data 32676 to end of string. I can save this file as book1 and sent you in last post as book1.xlsx. It was not corrupted. If we re-open it, it get opened without any warning.
Now if I do it programatically by loading workbook as setting that CheckExcelRestriction flag to false and then assign string which have length more than 32676 to cell A1 then its taking only string upto 32676 and remaining string get trim from right. But if I tried to open this excel, it is corrupted.
Here with ASPOSE, excel get corrupted is only issue. That string get trim is ok for me.
So is it expected behavior or ASPOSE team will fix this issue.
Please let me know otherwise I need to trim my string before put into as cell value.
Well, as I said, using our latest version/fix v8.2.0.3, there seems to me an issue with the product as when I used my code segment (above) with your template file, I still got the error when I opened the output file into MS Excel (2007/ 2010). We need to evaluate your issue thoroughly and will figure it out soon.
Once we have any update on it, we will let you know here.
Please try the latest version of Aspose.Cells for Java 8.2.1.2 as we have fixed the issue logged earlier as CELLSJAVA-40986 with this release. Please feel free to write back in case you face any difficulty.
I have evaluated the presented scenario while using the following piece of code against the latest version of Aspose.Cells for Java 16.11.4. I am afraid, I am not able to observe any problem with the resultant spreadsheet. I believe the said issue has already been resolved therefore you should first give the latest version a try on your end. In case the problem persists, please provide us an executable sample application along with the input spreadsheet (if any). Moreover, we strongly suggest you to create a new thread with your samples so that all notifications regarding that thread are sent to you.
Java
LoadOptions options = new LoadOptions(); options.setCheckExcelRestriction(false); Workbook excel = new Workbook(dir + “book1.xlsx”, options); Cells cells = excel.getWorksheets().get(0).getCells(); //Put a string into a cell Cell cell = cells.get(0, 0); StringBuilder sb = new StringBuilder(33000); for (int i = 0; i < 33000; i++) sb.append(“x”); String longVal = sb.toString(); cell.putValue(longVal); System.out.println(cell.getStringValue()); excel.save(dir + “output.xlsx”);