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

Free Support Forum - aspose.com

Can't save as xlsx

I’m running a simple example in ColdFusion where I’m trying to open an XLS document and save as XLSX. I’ve been able to open the XLS and save the XLS file as xls, csv and htm.

This is the error I get when saving as XLSX.
<!–[if gte mso 9]>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;}


org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory Nested exception: org.dom4j.DocumentFactory cannot be cast to org.dom4j.DocumentFactory

Using aspose-cells-7.1.0.jar and
dom4j-1.6.1.jar is in my classpath.

<cfset opt = createObject(“java”,“com.aspose.cells.OoxmlSaveOptions”)>
<cfset SaveFormat = createObject(“java”,“com.aspose.cells.SaveFormat”)/>
<cfset workbook=CreateObject(“java”, “com.aspose.cells.Workbook”).init("#outputFile#")>
<cfset opt.setSaveFormat(SaveFormat.XLSX) />
<cfset workbook.save("#variables.templateLocation#sampleDoc97.xlsx",opt)/>


Please download and try the latest version:

Aspose.Cells for Java 7.1.0

If the problem still occurs, then please provide us your source xls/xlsx file


Would you please check whether there are more than one dom4j library used in your environment?

Such as one is loaded by the server’s global library and one is loaded from application’s library. If true please only keep one and remove others.

There were 2 dom4j-1.6.1.jar files.

I removed 1 of the files from my Aspose classpath and left the other one in the server classpath. I can now save without an error, but the resulting XLSX file is unreadable by Excel.

I suspect that the dom4j-1.6.1.jar files are not equal even though they have the same name?

Is there any way that I can load the Aspose jar files separately from the Server jar files? It will be a maintenance nightmare if we have to intermingle server and Aspose jar files.


This may help some other ColdFusion users. The use of JavaLoader can help you get around this issue:

Google Groups

<cfset arrayAppend(paths, directory & “/” & name)>

_Thread = createObject(“java”, “java.lang.Thread”); //using ‘Thread’ breaks CFB
currentClassloader = _Thread.currentThread().getContextClassLoader();


// requires loadColdFusionClassPath=true param
loader = createObject(“component”,“javaloader.JavaLoader”).init(loadPaths=paths,loadColdFusionClassPath=true);

//set the current thread’s context class loader as Javaloader’s classloader, so dom4j doesn’t die


variables.templateLocation = “g:\docs\cells”;

//open file
FileFormatType = loader.create(“com.aspose.cells.FileFormatType”);
loadOpt = loader.create(“com.aspose.cells.LoadOptions”).init(FileFormatType.XLSX);
outputFile = “#variables.templateLocation#sampleDocOpen.xlsx”;

//save file
saveOptions = createObject(“java”,“com.aspose.cells.OoxmlSaveOptions”);
SaveFormat = createObject(“java”,“com.aspose.cells.SaveFormat”);

catch(Any exc)
We have to reset the classloader, due to
thread pooling.



Thanks for your posting and helping other users.

I think, you should use the dom Jar file as provided by

Aspose.Cells for Java 7.1.0
instead of Server’s file. Extract the one which is related to your JDK version.

Let me know if it solves your problem.


Please send us your template file and resultant file, we will test and check whether it is issue of our component or your environment.