I'm trying to format Column Number 5 to number. I know that formatting can be done by setCellStyle but how can i implement the same in my below code?
FileInputStream ExcelFileToRead = null;
HSSFWorkbook wb = null;
FileOutputStream outputStream = null;
short colNum = 5;
try {
ExcelFileToRead = new FileInputStream("config/test/test.xls");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
wb = new HSSFWorkbook(ExcelFileToRead);
} catch (IOException e) {
e.printStackTrace();
}
HSSFSheet sheet = wb.getSheetAt(0);
HSSFCell cell = null;
HSSFRow row = null;
sheet.createRow(0).createCell((short) 6).setCellValue("100");
sheet.createRow(3).createCell(colNum).setCellValue("120");
sheet.createRow(5).createCell(colNum).setCellValue("300");
sheet.createRow(11).createCell(colNum).setCellValue("500");
sheet.createRow(15).createCell(colNum).setCellValue("900");
sheet.createRow(18).createCell(colNum).setCellValue("1000");
sheet.createRow(23).createCell(colNum).setCellValue("10");
sheet.createRow(28).createCell(colNum).setCellValue("20");
sheet.createRow(30).createCell(colNum).setCellValue("30");
sheet.createRow(49).createCell(colNum).setCellValue("40");
outputStream = new FileOutputStream("config/test/test.xls");
wb.write(outputStream);
outputStream.close();