Delete Column in Excel in C#, VB.NET

  • Demo
  • C# source
  • VB.Net source

The sample demonstrates how to delete workbook column in Excel workbook via Spire.XLS.

using Spire.Xls;

namespace DeleteColumn
{
    class Program
    {
        static void Main(string[] args)
        {
            Workbook workbook = new Workbook();
            workbook.LoadFromFile(@"..\..\..\..\Data\vendors.xls",ExcelVersion.Version97to2003);
            Worksheet sheet = workbook.Worksheets[0];
 
            //delete the first column of sheet
            sheet.DeleteColumn(1); 

            workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003);
            System.Diagnostics.Process.Start(workbook.FileName);
        }
    }
}

Imports Spire.Xls

Namespace DeleteColumn
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			Dim workbook As New Workbook()
			workbook.LoadFromFile("..\..\..\..\Data\vendors.xls",ExcelVersion.Version97to2003)
			Dim sheet As Worksheet = workbook.Worksheets(0)

			'delete the first column of sheet
			sheet.DeleteColumn(1)

			workbook.SaveToFile("sample.xls", ExcelVersion.Version97to2003)
			System.Diagnostics.Process.Start(workbook.FileName)
		End Sub
	End Class
End Namespace