Excel XML error: “Too many tags”

17 Feb 2006  in mid-morning  Matt Winckler

When generating an Excel spreadsheet from XML (I’m using XSLT to transform some original XML into a workbook following Microsoft’s schema), the other day I ran into a problem opening the workbook. It described the error as “Workbook Setting” and referenced a logfile. The logfile contains the following highly informative text:

XML ERROR in Workbook Setting
REASON: Too many tags
FILE: C:\DOCUME~1\d3m853\LOCALS~1\Temp\GenerateCostsheet-44.xls
GROUP:  Workbook
TAG:    Worksheet
ATTRIB: Name
VALUE:  IDC-Subtask1

In typical Microsoft fashion, it tells you almost nothing useful. “Too many tags”? As it turns out, what this means is that there are two worksheets named the same thing, which is Not Allowed. (I don’t know how I could have misunderstood the error message the first time - obviously it’s talking about two worksheet names that are the same!) Name the worksheets something unique, and the problem will go away.

Some days I am absolutely convinced that the knave responsible for this skullduggery must have eaten his pet cat and picked up intrinsic Aggravate Monster. (”You have a feeling that eating the housecat was a bad idea. -- more --“) Or maybe the magic marker he used to write scrolls of error handling was cursed or something.

14 vociferations follow:

  1. amt 24 Jan 2007 // 10:10, chris responded:

    Thanks! I ran into this crap recently as well

  2. * * * * *
    pmt 09 Feb 2007 // 16:05, Scott responded:

    Thanks from here too! You saved my butt. Great detective work.

  3. * * * * *
    amt 12 Apr 2007 // 00:07, Robert responded:

    Thanks from me as well. I should have remembered it as its not the first time ive come across it.

  4. * * * * *
    amt 29 May 2007 // 08:14, Russ responded:

    Thanks - great help!

  5. * * * * *
    amt 17 Jul 2007 // 02:30, Kannan responded:

    Before seeing your solution, I am confused and unable to fix the prob.
    Now very happy.
    Regards

  6. * * * * *
    amt 07 Oct 2007 // 04:07, NGHI responded:

    Yes, that’s correct for one bad defined XMLExcel file.
    But I get this issue when my website export one XMLExcel file with 5 Sheets.

    If I save this file to local storage then open it - this issue never occurs.
    But I chose directly open this file then sometime this issue occur.

    Have you got any idea?

    Thanks & best regards,

  7. * * * * *
    amt 06 Dec 2007 // 01:34, Pete The Van responded:

    Marvelous work! Exactly my problem too! Thanks.

  8. * * * * *
    amt 15 Jan 2008 // 05:49, Jason responded:

    I got this error when adding cells to a worksheet but not ‘trimming’ the strings correctly. Adding the cells would work if I did it with a bit of test data statically in the code but when I referenced real data from a row in a dataset I had to ‘trim’ the strings with the VB.NET function ‘.trim’. Perhaps it’s my particular data but it’s worth mentioning.

  9. * * * * *
    amt 28 Apr 2008 // 10:40, RL responded:

    This happened to me recently with a monsterous spreadsheet that had a duplicate ‘Default’ style (two entries with the same Id tag seems to be the trick). When I exported it, there were two ‘Default’ styles in the tag, causing an error when re-opening the XML file. Removing it from the XML eliminated the problem. Now I just have to figure out how to get rid of this odd style.

  10. * * * * *
    amt 13 May 2008 // 06:43, Adrian responded:

    My errors were:

    XML ERROR in Style
    REASON: Bad Value

    XML ERROR in Style
    REASON: Too many tags

    Solved them by removing the tag at the beginning of the XML.

  11. * * * * *
    amt 13 May 2008 // 06:55, Adrian responded:

    By removing the nameless ‘default’ tag, I meant.

  12. * * * * *
    amt 01 Jul 2008 // 02:33, Alan Painter responded:

    I ran into something similar from a .xml written by Excel 2003.


    XML ERROR in Style
    REASON: Too many tags
    FILE: MyFileName.xml
    GROUP: Styles
    TAG: Style
    ATTRIB: Name
    VALUE: Normal

    Turned out that two Style elements had the same ss:Name attribute values. Both “Default” and “s21″ had ss:Name=”Normal”.

    I got rid of one of the name attributes ( the one on the Default Style) and Excel read again. Upon re-writing, the second “Normal” was magically changed to “Normal_”.

  13. * * * * *
    amt 15 Jul 2008 // 07:06, TulsaDev responded:

    I also cam across this error while trying to use the CarlosAg.ExcelXmlWriter.

    I had multiple sheets in a workbook, which were named uniquely, but I then added a style, and style names must be unique for each worksheet as well.

    I ended up appending the worksheet name to the style name.

  14. * * * * *
    pmt 21 Aug 2008 // 12:51, Kunal Bhambhani responded:

    In my case I was getting the follwoing error:-
    XML ERROR in Workbook Setting
    REASON: Too many tags
    FILE: C:\Documents and Settings\mylogin\Local Settings\Temporary Internet Files\Content.IE5\KTEZW9ER\PCAPAnalysis[1].xls
    GROUP: Workbook
    TAG: Worksheet
    ATTRIB: Name
    VALUE: Detailed Report

    It does not come up anymore since I changed the name of the file to a dynamically generated random number in the contentdisposition header of the response. I have a web application and having the same filename in the response header some how gave teh above error.

React

This comment form is Markdown-enabled, in addition to allowing the following XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .