Thursday, October 18, 2007

XML PARSE ERROR: Missing end-tag - Error in Export to Excel

Last week i was debugging a strange problem which came in the export to excel option in one of our web page. We have a export method which, will accept the dataset and will loop through it and builds the XML schema for the excel.

When we were using this excel method to export some data, it went fine and the response rendered the Open or Save dialog box. But when we try to open the excel file it gave a error stating the following

Problem came up in following areas during load:


This file cannot be opened because of errors. Errors are listed in: C:\Documents and Settings\UserId\Local Settings\Temporary Internet Files\Content.MSO\90797611.log

And when we open the specified 90797611.log file the message it had was,

XML PARSE ERROR: Missing end-tag
Error occurs at or below this element stack:

By looking in to this i was not able to get any thing, after doing some R&D I came to a conclusion that there were some problem with regarding "<ss:Font> <ss:B> <ss:I>".

Finally i decided to have a look at the dataset which is supplied to the export method, and to my surprise there was a field with the following data in it

<Font colour="green"><B><I>7358</B></I></Font>

As we are building a XML, the <Font colour="green"> got treated as a XML tag and it was expecting a corresponding end tag. This created the whole problem.

After removing <Font colour="green"><B><I> from the data, every thing worked fine.


Anonymous said...

Thanks to your suggestion. I was able to remove the
that was gave me the same error

Anonymous said...

The one thing I did was save the document to my pc and then open the excel document with notepad. I looked at the last line in the error log and then did a search for the
inside of notepad. I deleted it and saved it. It works now.