title: OpenXML for Excel - A document must contain exactly one root element. Line 1, column 0
body: <p>*<em>strong text</em>*I am trying to create and write to excel. For the template, I simply copied over code from OPENXML Productivity tool for an existing excel file, and then modified the code to add my rows of data when a new file is created from that code. However, I seem to be having some issue getting this to work correctly. I keep getting a </p>
  
  <p><strong>ccannot open the file : part /xl/worksheets/sheet2: Root element is missing
  Replaced Part: /xl/worksheets/sheet2.xml part with XML error.  A document must contain exactly one root element. Line 1, column 0.</strong></p>
  
  <p>error which I am still unable to correctly debug. Also, in the original template, there were 3 sheets in my workbook. I made sure to delete two of them so I can have just the code for the one created, as I assumed the OpenXML 2.0 Productivity tool would only generate code for the sheet that existed at the time document code was put together. But what happens is that the generated file has all 4 of the original sheets in place, but seems to not be able to put together the headers on each. </p>
  
  <p>Wanted to get some hints as to where to go to find this problem and fix it. thanks in advance. </p>
  
  <pre><code>   public void CreatePackage(string filePath)
          {
              using (SpreadsheetDocument package = SpreadsheetDocument.Create(filePath, SpreadsheetDocumentType.Workbook))
              {
                  CreateParts(package);
              }
          }
  
          private void CreateParts(SpreadsheetDocument document)
          {
              ExtendedFilePropertiesPart extendedFilePropertiesPart1 = document.AddNewPart&lt;ExtendedFilePropertiesPart&gt;("rId3");
              GenerateExtendedFilePropertiesPart1Content(extendedFilePropertiesPart1);
  
              WorkbookPart workbookPart1 = document.AddWorkbookPart();
              GenerateWorkbookPart1Content(workbookPart1);
  
              WorkbookStylesPart workbookStylesPart1 = workbookPart1.AddNewPart&lt;WorkbookStylesPart&gt;("rId3");
              GenerateWorkbookStylesPart1Content(workbookStylesPart1);
  
              ThemePart themePart1 = workbookPart1.AddNewPart&lt;ThemePart&gt;("rId2");
              GenerateThemePart1Content(themePart1);
  
              WorksheetPart worksheetPart1 = workbookPart1.AddNewPart&lt;WorksheetPart&gt;("rId1");
              GenerateWorksheetPart1Content(worksheetPart1);
  
              WorksheetCommentsPart worksheetCommentsPart1 = worksheetPart1.AddNewPart&lt;WorksheetCommentsPart&gt;("rId2");
              GenerateWorksheetCommentsPart1Content(worksheetCommentsPart1);
  
              VmlDrawingPart vmlDrawingPart1 = worksheetPart1.AddNewPart&lt;VmlDrawingPart&gt;("rId1");
              GenerateVmlDrawingPart1Content(vmlDrawingPart1);
  
              SharedStringTablePart sharedStringTablePart1 = workbookPart1.AddNewPart&lt;SharedStringTablePart&gt;("rId4");
              GenerateSharedStringTablePart1Content(sharedStringTablePart1);
  
              SetPackageProperties(document);
          }
  </code></pre>