Hello,
I have a problem executing as unit test a functionality that exports an excel area as HTML.
I save HTML in a ByteArrayOutputStream, but it uses anyway a sort of cache on filesystem, on my PC it uses my windows temp.
The problem occurs when I execute test on continuous integration system, where I have not a temporary writable filesystem folder.
java.io.FileNotFoundException: /tmp_files_files/sheet001.htm (No such file or directory)
Code is more or less this.
private static final String AREAHTML = "HTML";
@Test
void getAreaAsHtmlTestB() throws Exception {
Workbook workbook = new Workbook(this.getClass().getResourceAsStream("/xlsx/ImagesAndChartsRendering.xlsx"));
WorksheetCollection worksheets = workbook.getWorksheets();
Range range = worksheets.getRangeByName(AREAHTML);
if (Objects.isNull(range) && AREAHTML.contains("!")) {
range = worksheets.getRangeByName(AREAHTML.split("!")[1]);
}
range.getWorksheet().getPageSetup().setPrintArea(range.getAddress());
HtmlSaveOptions options = new HtmlSaveOptions(SaveFormat.HTML);
options.setExportPrintAreaOnly(true);
options.setExportBogusRowData(false);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
workbook.save(byteArrayOutputStream, options);
String html = byteArrayOutputStream.toString(StandardCharsets.UTF_8);
Assertions.assertNotNull(html);
}
Is it possible to avoid using temporary folder if I’m saving in an output stream?
otherwise how can I set this folder by code and not system properties?
Thanks