private void AddColumns(SpreadsheetDocument doc, string sheetName) { var sheetData = doc.GetSheetDataByName(sheetName); var headerRow = sheetData.Descendants<Row>().FirstOrDefault(); if (headerRow == null) return; var colCount = headerRow.Descendants<Cell>().Count(); var columnRange = Enumerable.Range(0, colCount).Select(i => CreateColumn(doc, sheetData, i)); var columns = new Columns(columnRange); var sheet = doc.GetWorksheetByName(sheetName); sheet.InsertAt(columns, 0); }