How to Write Data into Excel File Using Apache POI

you can try these out dating my car How to Write Data into Excel File Using Apache POI

try this web-site

rencontre consciente Writing a file using POI is very simple and involve following steps:

  1. Create a workbook
  2. Create a sheet in workbook
  3. Create a row in sheet
  4. Add cells in sheet
  5. Repeat step 3 and 4 to write more data package pack2; import; import; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; public class ExcelWrite { public static void main(String[] args) throws IOException { XSSFWorkbook wb1 = new XSSFWorkbook(); XSSFSheet sheet11 = wb1.createSheet("My Sheet"); XSSFRow row1 = sheet11.createRow(1); XSSFCell cell0 = row1.createCell(0); cell0.setCellValue(12); XSSFCell cell1 = row1.createCell(1); cell1.setCellValue(23); XSSFCell cell2 = row1.createCell(2); cell2.setCellValue(34); XSSFCell cell3 = row1.createCell(3); cell3.setCellValue(43); XSSFCell cell4 = row1.createCell(4); cell4.setCellValue(11); XSSFCell cell5 = row1.createCell(5); cell5.setCellValue(121); FileOutputStream fileOut = new FileOutputStream("D:\\MyExcel.xlsx"); wb1.write(fileOut); fileOut.flush(); fileOut.close(); wb1.close(); } } On executing the above code, you get below excel as an output.

my site