Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 19, 2024

Conversation

houlongchao
Copy link
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
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
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.

@tonyqus tonyqus added this to the NPOI 2.7.2 milestone Oct 19, 2024
@tonyqus tonyqus merged commit 7bc2131 into nissl-lab:master Oct 19, 2024
3 checks passed
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