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;
The ws.Cells[]
return type is ExcelRange which has a Dispose() method.
Do I need to call it each time I use ws.Cells[]
?
Something like
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 !
Is it really necessary ?
The answer is no.
Why?
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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With