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

Free Support Forum - aspose.com

Converting to XLSX using XSLT


We are using XSLT to generate XLS report output in our project using some custom code. Now we want the same output in XLSX format. Please note that we are currently not using Aspose for this.

As we apsose for our other reports; is there anything in aspose which can help us on this? We are not in a opinion of updating XSLT file. If there is some easy way out in aspose, please let us know. Might be something like we will generate the files in XLS only as per our earlier logic and later convert them to XLSX using Aspose.

thanks in advance…!!


Thanks for your query.

Well, Aspose.Cells is a spreadsheet management library, it supports to create, manipulate, render or print MS Excel file formats only (e.g XLS, XLSX, XLSM, XLSB, CSV, Tab delimited, ODS, SpreadsheetML etc.). I am afraid, it does not support or manipulate XSLT for XLS/XLSX conversions as it is out of scope.

And, yes, I think for your requirements, you may first convert to XLS (using your own custom code and logic with XSLT) and then use Aspose.Cells APIs to convert XLS to XLSX easily.

Thank you.

thanks for your reply.
Now this is our final piece of code which generates results.xls. I have tried saving the file as xlsx but did not work. Can you please tell how to write that code for integrating transformations from xls to XLSX??

private void DownloadFile(string filePath, string filename)
if (filename == string.Empty)
filename = “results.xls”;

Response.Buffer = true;
Response.ContentType = “application/vnd.ms-excel”;
// Response.ContentType = “application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”;

Response.AddHeader(“content-disposition”, “attachment;filename=” + filename);


After this function; we directly see the excel file popped up in browser.


Before I got reply from you; this piece of code worked at my end.

Workbook wk = new Workbook(filePath);
wk.Save(filePath, SaveFormat.Xlsx);

I have added the same before Response.TransmitFile(filePath) and it worked.
Please let us know if there is any better/alternate way of doing this.

Many Thanks for your help…!!!


I am afraid, I might not help you much regarding transformations using XSLT to XLSX. I asked you to simply use Aspose.Cells APIs to render your converted XLS file (using your own custom code) to XLSX via Aspose.Cells APIs, e.g see the following sample code for your reference:
Sample code:

//Load your XLS file into Workbook object, you may get the file into streams etc.
Workbook workbook = new Workbook(strFileName);
workbook.Save(“out1.xlsx”, SaveFormat.Xlsx) ;

PS. Ok, you got it right finally.

Thank you.


As mentioned earlier, the following piece of code works fine with us.
Workbook outputWorkbook = new Workbook(filePath);
outputWorkbook.Save(filePath, SaveFormat.Xlsx);

But in few cases we get error in the second line while Saving that the file is used by another process. this only happens in few cases…

Is there anything like workbook.Close(), Quit() before we save the same as XLSX?


You can call Workbook.Dispose method, once you are done with the Workbook object. Regarding the error, could you please provide more details of the said error along with the spreadsheet that caused it? We will look into the presented scenario in more detail to provide further assistance in this regard.


Please note, when Aspose.Cells saves the workbook, it creates a new file, it means the contents of old file are deleted or overwritten with the same name. So, suppose if some file say “Sample.xlsx” is already opened by another process or openend in MS Excel, then Aspose.Cells will not be able to re-save the file and it will give exception saying:
The process cannot access ‘…\Sample.xlsx’ because it is being used by another process.

So, you must release Sample.xlsx file from other process or from Excel first, so, Aspose.Cells could save the file with the same name. Alternatively, you may re-save the file by different name.

Thank you.