Hi All,
I am getting Bad file descriptor error message while trying to run the below code :
try {
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow((short) 0);
rowhead.createCell((short) 0).setCellValue("Roll No");
rowhead.createCell((short) 1).setCellValue("Name");
rowhead.createCell((short) 2).setCellValue("Class");
rowhead.createCell((short) 3).setCellValue("Marks");
rowhead.createCell((short) 4).setCellValue("Grade");
int index = 1;
while (index<=110){
HSSFRow row = sheet.createRow((short) index);
row.createCell((short) 0).setCellValue(index);
row.createCell((short) 1).setCellValue("Java");
row.createCell((short) 2).setCellValue("Write to Excel");
row.createCell((short) 3).setCellValue(index+15);
row.createCell((short) 4).setCellValue("NA");
index++;
}
FileOutputStream fileOut = new FileOutputStream("\\\\remotepc1111\\C$\\test\\TestExcel.xls");
wb.write(fileOut);
fileOut.close();
}
catch (Exception e) {
System.out.println(e.getMessage());
}
I read some where on the internet that this could be because of fileOut.close(). I tried after commenting that, but result was same.
Could some one point me what mistake I am making.
Thanks a lot.
AR