清除列中的数据 [英] Clear data in column
本文介绍了清除列中的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试对EPPlus电子表格使用标准的 .Clear()
方法,但没有任何运气。有谁知道如何使用EPPlus插件清除列中的所有数据?以下是我到目前为止所拥有的。不会引发异常,但是根本不起作用。
I'm trying to use the standard .Clear()
method for an EPPlus spreadsheet without any luck. Anyone know how to clear all the data in a column using the EPPlus plugin? Below is what i have so far. Does not throw an exception but doesn't work at all.
if (File.Exists(path))
{
//Connect to spreadsheet
FileStream stream = File.Open(path, FileMode.Open, FileAccess.Read);
FileInfo file = new FileInfo(path);
_package = new ExcelPackage();
//Pull data into EPPlus object
_package.Load(stream);
_sheet = _package.Workbook.Worksheets.First();
//Clear out previous errors
_sheet.Cells["L1"].Clear();
}
推荐答案
我稍微使用了ExcelPackage不同(假设我们在谈论同一个DLL):
I use the ExcelPackage a little differently (assuming we are talking about the same DLL):
public static FileInfo existingFile =
new FileInfo(@"C:\Users\cle1394\Desktop\ExampleExcelFile.xlsx");
using (ExcelPackage xlPackage = new ExcelPackage(existingFile))
{
ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets[1];
// clear value
worksheet.Cell(iRow, 1).Value = "";
}
尝试一下,让我知道它是否有效。
Try that, let me know if it works.
这篇关于清除列中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文