I declared internal variables in this way:
FileOutputStream fos;
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("analyze_result");
Row row = sheet.createRow(rowIndex);
Cell cell = row.createCell(cellIndex);
HSSFCellStyle cs = workbook.createCellStyle();
In the middle of the class, after I collect some importent data I send it to the next function, but in the result it seems that no change performed on my excel:
private void firstWriteToExcel(DefectFileReader curDF , HSSFSheet sheet , HSSFWorkbook workbook , FileOutputStream fos) throws Exception{
cs.setWrapText(true);
cs.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
if(recipeName.getState() == true){
row = sheet.createRow(rowIndex - 1);
row.createCell(cellIndex).setCellValue("Recipe Name: " + curDF.getRecipeName());
cell.setCellStyle(cs);
}
row = sheet.createRow(rowIndex++);
row.createCell(cellIndex++).setCellValue("inspection index");
row.setRowStyle(cs);
if(numberOfDefects.getState() == true){
System.out.println("in printing to excel");
row.createCell(cellIndex++).setCellValue("Total Defects");
}
if(numberOfDefectsPerDetector.getState() == true){
ArrayList<String> toOtherFunc = new ArrayList<String>();
toOtherFunc = curDF.getDetectorNames();
for(int i=0; i < toOtherFunc.size() ; i++)
row.createCell(cellIndex++).setCellValue(toOtherFunc.get(i));
}
if(sensetivityName.getState() == true)
row.createCell(cellIndex++).setCellValue("sensetivity Name");
if(inspectionDuration.getState()==true)
row.createCell(cellIndex++).setCellValue("Inspection Duration");
row.setRowStyle(cs);
System.out.println("row index is: " + rowIndex + "cell index is: " + cellIndex);
}