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

Free Support Forum - aspose.com

SpreadsheetML - Invalid file format requested

Hi,

I am trialling Aspose Cells (4.4.3.1) using Visual Studio 2005 and Windows XP
I need to be able to load and save Excel 2003 XML Spreadsheet files, and to do this I assume I need to save in the SpreadsheetML FileFormatType.

In a C# web application I have been able to load this format, but when I try to save in theSpreadsheetML format I get the following error:

" System.ArgumentException: Invalid file format requested."

Even if I just create a new workbook I also get this error when I save in that format, although the other file format types all work fine when saving - either new files or loading from existing files.

Here is an example of the code I tried in the click event of a button in an aspx page:

protected void Button1_Click(object sender, EventArgs e)
{
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells[0, 0].PutValue(“row 1 cell 1”);
workbook.Save(“wrk1.xml”, SaveType.OpenInBrowser, FileFormatType.SpreadsheetML, Response);
}

Thanks for your help.


Hi,

Thanks for considering Aspose.

I don't find the problem you have mentioned. I implemented your code and it works fine.

Could you try the latest version / fix (4.4.3.15) attached @ the thread: <A href="</A> </P> <P>Thank you.</P>

Thanks for your quick response, but unfortunately the update did not make a difference.

I made sure the dll deployed to the bin directory was 4.4.3.15. I also tried it on another development environment and got the same error.

Hi,

We have found this issue. We will post a fix soon. Thanks for you patience.

Hi,

Please try the fix in <A href="</A></P>

Hi Warren,

Although clicking the link you posted produces an error “wlmailhtml is not a registered protocol”, I went to that forum post and installed 4.4.3.16.

I no longer get the original error when I run the example I posted earilier, but now in the test web page where I am clicking the test button it just seems to get posted back as the response, this is what I now see:




Untitled Page














If I change the format type to FileFormatType.Excel2003 for example, then it still works fine.

Hi,

Please try this fix.

Hi,

This fix does now generate an xml file, but I am concerned to see that if I view the file in a text editor, the html page that made the request is embeded at the bottom of the file, obviously making it an invalid xml document.

I have also noticed that if I specify the file extension to be “.xml” it is still saved as “.xls”, and that if I try to load a file and then save it, some formatting seems to be lost, such as tab colors.

Hi,

Please try this fix. We have supported tab color in exporting and importing spreadml.

We call this line code use "application/vnd.ms-excel" as response.ContentType. IE will auto change the extension to ".xls". We tried other Content Type, we found that IE will not call MS Excel to open it if we want to open the file in IE. If you have an idea on Content Type, please tell us.

Hi,

I think the tab color is now being retained thanks, but was this fix also supposed to fix the problem where the the html page that made the request is embeded at the bottom of the xml file, as I am still seeing this problem?

Hi,

Please call Reponse.End() method after Wokbook.Save() method to remove the html page which embeded at the xml file..See following codes:

Workbook workbook = new Workbook();
workbook.Worksheets[0].Cells["A1"].PutValue("Hello");
workbook.Save("test.xml", FileFormatType.SpreadsheetML, SaveType.OpenInBrowser, Response);
Response.End();

That works well now, thanks for all your help.