I'm creating a method to hide elements that are zeroed out of an excel file, but the problem is that it can not pick up the values when the column is a formula. How can I get these values?
My code:
private static ByteArrayOutputStream ocultarZerados(ByteArrayOutputStream arquivo) throws Exception
{
InputStream arquivoExcel = new ByteArrayInputStream(arquivo.toByteArray());
XSSFWorkbook wb = new XSSFWorkbook(arquivoExcel);
XSSFSheet s = (XSSFSheet) wb.getSheetAt(1);
for (Row linha : s)
{
System.out.println("===================");
for (Cell coluna : linha)
{
if(coluna.getCellType() == 1)
{
System.out.print(coluna.getStringCellValue() + "|");
}
else {
System.out.print(coluna.getNumericCellValue() + "|");
}
}
System.out.println("===================");
}
wb.write(arquivo);
wb.close();
return arquivo;
}