Skip to content

OpenXML Excel program error

A Repasky

Asked Dec 28, 2011, 8:22 AM EST2 answers
Share
LinkedInX
I am getting the following error when I try to open the file.  I just started testing this and I do not know what to do.  So the code is very preliminary.  The code for the class is attached.  I only have about a year of C# experience and have not used OpenXML before and the lead programmer is hard to work for.

I want to be able to send a table (or change it to a list or class or something) to this class to make a xlsx spreadsheet.  We want to eliminate the need for Excel.  This is for health care field. 

Thanks for any help I can get on this.

Arep

Replaced Part: /xl/worksheets/sheet.xml part with XML error.  A document must contain exactly one root element. Line 1, column 0.

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    I have been working on this.  I fixed the other problem above.  The problem was by the first line.  I was calling it multiple times to set the columns. 

    Python
                columns.Append(CreateColumnData(1, (UInt32)dt.Columns.Count, 20));
    
     
    But the only thing that works now is the columns width.  It does open the spreadsheet,but except for the wider
    columns, nothing else is in the spreadsheet.  The sheet name has changed also.
    
     
    Thanks for any help.
    
     
    Arep
    0
  • 0
    Here is the code that works.  I had the
    Code
    row = new Row();
    in the inner for loop and the
    Code
          rowCnt++;
          sd.Append(row); 
    
     
    in the for loop also.
    
     
    It now works.
    
     
    Arep
     
    PS. I would like to close this out, but I do not see the option.
    0