excel-streaming-reader icon indicating copy to clipboard operation
excel-streaming-reader copied to clipboard

AutoClosing doesn't seem to remove tmp files.

Open GummyDonut opened this issue 3 years ago • 1 comments

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());
      }
    }
  }
}

GummyDonut avatar Jun 01 '21 17:06 GummyDonut

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 .

monitorjbl avatar Jun 01 '21 17:06 monitorjbl