删除行
using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Deleterow
{
class Program
{
static void Main(string[] args)
{
FileInfo file = new FileInfo(@"D:\武天设计资料\11 互提资料单\测量\测量提\互通服务区中桩断面6.27\管理所中桩断面\管理所中桩断面\管理所断面 - 副本.xlsx");
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;//获取许可
using (ExcelPackage excelPackage = new ExcelPackage(file))
{
ExcelWorksheet excelWorksheet = excelPackage.Workbook.Worksheets["CPA"];
//var excelWorksheet = excelPackage.Workbook.Worksheets.FirstOrDefault();
for (int i = 0; i < 200; i++)
{
excelWorksheet.DeleteRow(i+2);
// excelWorksheet.DeleteRow(i+2);
}
excelPackage.Save();
}
}
}
}