Although this adds multiple sheets, it currupts the excel file.
using (SpreadsheetDocument document = SpreadsheetDocument.Create(@"C:\Users\Public\Documents\sheets10.xlsx", SpreadsheetDocumentType.Workbook))
{
//// Add a WorkbookPart to the document.
WorkbookPart workbookPart = document.AddWorkbookPart();
workbookPart.Workbook = new Workbook();
//// Add a WorksheetPart to the WorkbookPart.
WorksheetPart worksheetPart = workbookPart.AddNewPart<WorksheetPart>();
worksheetPart.Worksheet = new Worksheet(new SheetData());
Sheets sheets = workbookPart.Workbook.AppendChild(new Sheets());
for (uint i = 0; i < 6; i++)
{
Sheet sheet = new Sheet() { Id = workbookPart.GetIdOfPart(worksheetPart), SheetId = i, Name = i.ToString() };
sheets.Append(sheet);
}
workbookPart.Workbook.Save();
}
Can someone advise why this does not work.