I recently upgraded to Aspose Cells for Java 7.0.2. When i am using this version some illegal characters are getting inserted to the xml files inside the xlsx file.
Here is the chunk of xml content.(of shee1.xml file.)
ï»¿<?xml version="1.0" encoding="utf-8" standalone="yes"?><worksheet x
The first few characters are not valid as per xml guidelines. I was not having this issue in earlier versions of aspose. Because of this I am having some issues for certain features with Office 2010.
can you please provide a fix for this?
the issue is still there with the new version
Any code would reproduce the issue.
here it is
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.getWorksheets().get(0);
Cell cell = worksheet.getCells().get(0, 0);
Style style = cell.getStyle();
style.setBackgroundColor(Color.fromArgb(255, 255, 255));
We have tested your code and even more complicated code but cannot find such kind of issue. We think maybe it is related with your environment.
Please provide us your generated xlsx file so we can make further investigation. Also please provide us more details about your enviornment, such as your OS, JDK, server and so on.
From V7.0 there are more third party libraries needed, please make sure you have put all of them into your classpath and have no confilict with other libraries.
I can see, you have one missing jar namely.
Please add it in your classpath and see if it resolves your issue.
We have looked into your "out.xlsx" file but cannot find any issue with it. This file can be opened fine in ms excel, both in excel2007 and excel2010. What's the trouble you got with this file? Could it be opened in your ms excel? Or you uncompressed those xml files and processed them by your code? If you cannot open it in your ms excel, please provide us your excel version(major and minor), we will test it again with the specific version. If you process those xml files with your own code, we think you need to process BOM of xml files by yourself. We think the illegal characters you talked about was the BOM(0xEF 0xBB 0xBF) of xml file. Having such BOM header or not are both valid for xml file with UTF-8 encoding(default encoding we used for creating xml file). However, by our experience, JDK's IO APIs cannot process BOM correctly. So user needs to check whether one XML file contains BOM header and remove it before process its content.
Also we will check whether we can remove the BOM header from the generated XML files without any other side effect. But for the robustness of code, we think it is better for user to check BOM in their code when processing xml files.
It works fine. Thank you!!