title: Open XML: Delete entire excel column using column index
body: <p>I have got column index for an excel column in a spreadsheet and need to delete the entire column using this column index. I am confined to use Open XML SDK 2.0.</p>
  
  <pre><code>using DocumentFormat.OpenXml.Packaging;
  using DocumentFormat.OpenXml.Spreadsheet;
  
  namespace openXMLDemo
  {
      public class Program
      {
          public static void Main(string[] args)
          {
              string fileFullPath = @"path to the excel file here";
              string sheetName = "excelsheet name here";
  
              using (SpreadsheetDocument document = SpreadsheetDocument.Open(fileFullPath, true))
              {
                  Sheet sheet = document.WorkbookPart.Workbook.GetFirstChild&lt;Sheets&gt;().Elements&lt;Sheet&gt;().Where(s =&gt; s.Name == sheetName).FirstOrDefault();
                  if (sheet != null)
                  {
                      WorksheetPart worksheetPart = (WorksheetPart)document.WorkbookPart.GetPartById(sheet.Id.Value);
  
                      // This is where I am struggling.... 
                      // finding the reference to entire column with the use of column index
                      Column columnToDelete = sheet.GetFirstChild&lt;SheetData&gt;().Elements&lt;Column&gt;()
                  }
              }
          }
      }    
  }
  </code></pre>