Skip to content

fixed SXSSFWorkbook can not clear temp files when it called Dispose() on the IWorkbook interface.#1385

Merged
tonyqus merged 1 commit into
nissl-lab:masterfrom
houlongchao:master
Oct 19, 2024
Merged

fixed SXSSFWorkbook can not clear temp files when it called Dispose() on the IWorkbook interface.#1385
tonyqus merged 1 commit into
nissl-lab:masterfrom
houlongchao:master

Conversation

@houlongchao
Copy link
Copy Markdown
Contributor

The floowing code generates 2 temp files and is not automatically cleaned. This change fixes the problem.

IWorkbook workbook = new SXSSFWorkbook();
var sheet = workbook.CreateSheet();
var row = sheet.CreateRow(0);
row.CreateCell(0).SetCellValue("test");

var sheet2 = workbook.CreateSheet();
var row2 = sheet2.CreateRow(0);
row2.CreateCell(0).SetCellValue("test");

workbook.Dispose();

@tonyqus
Copy link
Copy Markdown
Member

tonyqus commented Jul 10, 2024

You should apply using on SXSSFWorkbook. Then dispose will call Close method. It makes sense.

using(IWorkbook workbook = new SXSSFWorkbook())
{
 ...
}

@houlongchao
Copy link
Copy Markdown
Contributor Author

I Know, but the close method only close the file, cleaning temp file only seen in the dispose method.
You can test it, the temp file cannot currently be cleaned using the IWorkbook dispose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants