Illegal characters in sheet1.xml

Hi,

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?

Thanks

Hi,

Please try the latest fix: v7.0.2.5, if you still find the issue, give us your template files and sample code to reproduce the issue.

We will check it soon.

Thank you.

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);

cell.setValue(“Pravat”);
Style style = cell.getStyle();

style.setPattern(BackgroundType.SOLID);
style.setBackgroundColor(Color.fromArgb(255, 255, 255));

workbook.save(“C:\Pravat\EclipseWS\Ascent\mass-xport-ws\Test1\src\outresult\bookTestCellBack.xlsx”);

Hi,

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.

Thank you.

Hi,


I am still able to replicate the issue with the least required jars in my class path. [ I could see the the issue in some relationship files also (*.rels)]. Attched the file.

1. Machine : Win XP SP3; Intel Core2 Duo processor
2. Editor : Eclipse Helios
3. Server : Apache tomcat 6.x [However I could replicate the issue using a simple Main class]
4. JRE : 1.6.0-26
5. JDK : 1.6
6. jars in class path : (along with eclipse default jre jars)
aspose-cells-7.0.2.jar
dom4j-1.6.1.jar
stax2-api-3.0.2.jar
woodstox-core-asl-4.1.1.jar

Attached the excel sheet and the java file.

Hi,

I can see, you have one missing jar namely.
bcprov-jdk16-146.jar

Please add it in your classpath and see if it resolves your issue.



Hi,

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.

Hi,


You are right. I am able to open the file in both 2007 and 2010. However, in my project I am using excel web queries (which I guess is not yet supported by Aspose). So I am manually creating/modifying the required xml files inside the archive using ooxml schemas. Issue is, when I am having those BOM headers (as u said) I am having issue when refreshing the file with excel 2010.

I have already written the code to remove all characters before the “<xml?..” tag. But again, for this I have bring those files to memory and remove the headers which certainly I never wanted as I have nothing to do with those files. If you are working on the issue of removing those headers, please let me know know you fix this.

Hi,


Please try our latest version:
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/entry342254.aspx

We have removed the BOM when creating xml files.

<o:p></o:p>

It works fine. Thank you!!