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.

13 vociferations follow:

  1. 11 months, 1 week after the fact, chris responded:

    Thanks! I ran into this crap recently as well

  2. * * * * *
    11 months, 3 weeks after the fact, Scott responded:

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

  3. * * * * *
    1 year, 1 month after the fact, Robert responded:

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

  4. * * * * *
    1 year, 3 months after the fact, Russ responded:

    Thanks - great help!

  5. * * * * *
    1 year, 4 months after the fact, Kannan responded:

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

  6. * * * * *
    1 year, 7 months after the fact, 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. * * * * *
    1 year, 9 months after the fact, Pete The Van responded:

    Marvelous work! Exactly my problem too! Thanks.

  8. * * * * *
    1 year, 11 months after the fact, 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. * * * * *
    2 years, 2 months after the fact, 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. * * * * *
    2 years, 2 months after the fact, 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. * * * * *
    2 years, 2 months after the fact, Adrian responded:

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

  12. * * * * *
    2 years, 4 months after the fact, 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. * * * * *
    2 years, 4 months after the fact, 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.

React

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