EPPlus - 我需要调用Dispose像ExcelRange对象? [英] EPPlus - Do I need to call Dispose on objects like ExcelRange?
本文介绍了EPPlus - 我需要调用Dispose像ExcelRange对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用C#EPPlus库创建Excel文档。
I'm using the C# EPPlus library to create Excel documents.
ExcelWorksheet ws = pkg.Workbook.Worksheets.Add("Sheet1");
ws.Cells["E3"].Value = "Foo";
ws.Cells["F3"].Value = "Bar";
ws.Cells["F3"].Style.Font.Bold = true;
的
ws.Cells []
返回类型是ExcelRange具有Dispose()方法。
我需要每次使用 ws.Cells []
?
The ws.Cells[]
return type is ExcelRange which has a Dispose() method.
Do I need to call it each time I use ws.Cells[]
?
喜欢的东西时调用它
ExcelWorksheet ws = pkg.Workbook.Worksheets.Add("Sheet1");
ExcelRange rng;
rng = ws.Cells["E3"];
rng.Value = "Foo";
rng.Dispose();
using (rng = ws.Cells["F3"])
{
rng.Value = "Bar";
rng.Style.Font.Bold = true;
}
将是一个沉重的语法!
would be a heavy syntax !
是不是真的有必要吗?
推荐答案
答案是否定的。
为什么?
我把从EPPlus源代码一看,这是处置的内容
的方法 ExcelRangeBase
:
I took a look in the source code from EPPlus and this is the content of the Dispose
method of the ExcelRangeBase
:
public void Dispose()
{
//_worksheet = null;
}
我不认为这会帮助你在任何方式..
I don't think this is going to help you in any way...
这篇关于EPPlus - 我需要调用Dispose像ExcelRange对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文