monitorjbl / excel-streaming-reader

An easy-to-use implementation of a streaming Excel reader using Apache POI
Apache License 2.0
959 stars 345 forks source link

AutoClosing doesn't seem to remove tmp files. #235

Open GummyDonut opened 3 years ago

GummyDonut commented 3 years ago

Thank you so much for this library, it saved us alot of time. I have a small question however?

Using the example provided(code below) on the ReadMe.md and version 2.1.0 of the library. The stream closes but the tmp file still exists until you run 'workbook.close()'. Is this intentional? Should the autoclosable not do this on its own?

try (
  InputStream is = new FileInputStream(new File("/path/to/workbook.xlsx"));
  Workbook workbook = StreamingReader.builder()
          .rowCacheSize(100)
          .bufferSize(4096)
          .open(is)) {
  for (Sheet sheet : workbook){
    System.out.println(sheet.getSheetName());
    for (Row r : sheet) {
      for (Cell c : r) {
        System.out.println(c.getStringCellValue());
      }
    }
  }
}
monitorjbl commented 3 years ago

It should, and I'm not sure why it wouldn't for you. The close() method is called by the try-with block; Autoclosable classes just have to implement that method.

On Tue, Jun 1, 2021, 1:11 PM Peter Hoang @.***> wrote:

Using the example provided(code below) on the ReadMe.md and version 2.1.0 of the library. The stream closes but the tmp file still exists until you run 'workbook.close()'. Is this intentional? Should the autoclosable not do this on its own?

try ( InputStream is = new FileInputStream(new File("/path/to/workbook.xlsx")); Workbook workbook = StreamingReader.builder() .rowCacheSize(100) .bufferSize(4096) .open(is)) { for (Sheet sheet : workbook){ System.out.println(sheet.getSheetName()); for (Row r : sheet) { for (Cell c : r) { System.out.println(c.getStringCellValue()); } } } }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/monitorjbl/excel-streaming-reader/issues/235, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIYRUCH4KQWGSIT22ELF7TTQUIFLANCNFSM455CR6FQ .