0
Я объявил внутренние переменные таким образом:Установить CellStyle в ячейку или строку в HSSFWorkbook
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();
В середине класса, после того, как я собираю некоторые ВАЖНЫЕ данные я отправить его к следующей функции, но в в результате, кажется, что никаких изменений не выполняется на моем первенствовать:
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);
}
Я не могу видеть код, в котором вы пишете изменили Excel файл из - вы забыли позвонить 'write', чтобы сохранить его? – Gagravarr
нет ... это позже в коде. превосходная печать хорошо не изменилась. – Udi
@Gagravarr у вас есть какая-то другая идея, пожалуйста? – Udi