Use C# to remove Excel columns/rows can be as easy as in Microsoft Excel. With the help of Spire.XLS, a professional .NET Excel component, we can finish the whole job in minutes. Download Spire.XLS and install on system. Follow the simple steps below to remove Excel columns/rows at will.
Step 1 Create Project
Create a C# project in Visual Studio and Add Spire.Xls.dll as reference. The default setting of Spire.Xls.dll is placed under "C:\Program Files\e-iceblue\Spire.Xls\Bin”. Select assembly Spire.Xls.dll and click OK to add it to the project.
static void Main(string args)
Step 2 Open Excel Document
Put the Excel document which we will remove columns/rows into the project folder. Use the code below to load and open it.
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets;
Step 3 Remove Excel Columns/Rows
Spire.XLS allows users to remove multiple columns/rows. The sample code below shows how to remove Excel columns/rows at will.
//delete the second row from sheet
//delete the seventh and eighth rows from sheet
//delete the first column of sheet
Step 4 Save and Preview
The following code can help us save the Excel file and preview the Excel worksheet.
After finish all coding job, we can fins the Excel file in the project folder bin ->debug. And because we can not see the deleted columns/rows, we can get a capture here.
More about Spire.XLS
Spire.XLS is a professional Excel component which enables developers/programmers to fast generate, read, write and modify Excel document for .NET and Silverlight. It supports C#, VB.NET, ASP.NET, ASP.NET MVC and Silverlight. Click to learn more…