title: Open XML Creating Multiple sheets
body: <p>I am trying to create an Excel file using Open XML C#, where there are multiple sheets in my excel file that needs to be created. Please find my code below and help me with a solution.</p>
  
  <p>When I open the excel only 1 sheet is present, sheet 2 is getting overwritten in sheet 1.</p>
  
  <pre><code>    public void CreateExcelFile(string filePath , List&lt;SheetData&gt; excelSheet)
      {
  
          var sheetCount = GetSheetCount(filePath);
  
  
          using (SpreadsheetDocument spreedDoc = SpreadsheetDocument.Create(filePath,
              DocumentFormat.OpenXml.SpreadsheetDocumentType.Workbook))
          {
              Workbook workbook1 = new Workbook();
              workbook1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
              FileVersion fileVersion1 = new FileVersion() { ApplicationName = "xl", LastEdited = "5", LowestEdited = "4", BuildVersion = "9302" };
              WorkbookProperties workbookProperties1 = new WorkbookProperties() { FilterPrivacy = true, DefaultThemeVersion = (UInt32Value)124226U };
  
              BookViews bookViews1 = new BookViews();
              WorkbookView workbookView1 = new WorkbookView() { XWindow = 240, YWindow = 105, WindowWidth = (UInt32Value)14805U, WindowHeight = (UInt32Value)8010U, ActiveTab = (UInt32Value)2U };
  
              bookViews1.Append(workbookView1);
              Sheets sheetCol = new Sheets();
  
              int ctr = 0;
              foreach (var sheetToCreate in excelSheet)
              {
                  ctr++;
  
                  //WorksheetPart worksheetPart = null;
                  //worksheetPart = wbPart.AddNewPart&lt;WorksheetPart&gt;();
                  //var sheetData = new SheetData();
  
                  //worksheetPart.Worksheet = new Worksheet(sheetData);
                  //worksheetPart.Worksheet = new Worksheet(sheetToCreate);
  
                  string sheetName = "Sheet";
  
  
                  sheetName += ctr.ToString();
  
  
  
                  var sheet = new Sheet()
                  {
                      Id = "rId" + ctr,
                      SheetId = (UInt32)ctr,
                      Name = sheetName
                  };
                  sheet.Append(sheetToCreate);
                  sheetCol.Append(sheet);
  
  
                  //wbPart.Workbook.Sheets.AppendChild(sheet);
                  //wbPart.Workbook.Append(sheetCol);
  
                  workbook1.Sheets.Append(sheet);
  
                  //var workingSheet = ((WorksheetPart)wbPart.GetPartById(sheet.Id)).Worksheet;
  
  
  
              }
              workbook1.Append(fileVersion1);
              workbook1.Append(workbookProperties1);
              workbook1.Append(bookViews1);
              workbook1.Append(sheetCol);
  
  
  
              //Set Border 
              //wbPark
  
              workbook1.Save();
          }
      }
  </code></pre>