Guest User

Untitled

a guest
Nov 18th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import java.io.IOException;
  2.  
  3. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  4. import org.apache.poi.ss.usermodel.Cell;
  5. import org.apache.poi.ss.usermodel.Row;
  6. import org.apache.poi.ss.usermodel.Workbook;
  7. import org.apache.poi.xssf.usermodel.XSSFSheet;
  8. import org.apache.poi.ss.usermodel.Sheet;
  9. import org.apache.poi.xssf.usermodel.XSSFWorkbook;
  10.  
  11. import java.io.FileNotFoundException;
  12. import java.io.FileOutputStream;
  13. import java.io.IOException;
  14.  
  15. public class ExcelFactory {
  16. private static final String FILE_NAME = "rex.xlsx";
  17.  
  18.  
  19. public static void main(String[] args) throws IOException {
  20. FileOutputStream file = new FileOutputStream(FILE_NAME);
  21.  
  22. Workbook wb = new HSSFWorkbook();
  23.  
  24. Sheet sh = wb.createSheet("firstSheet");
  25. Row row = sh.createRow(0);
  26. Cell cell = row.createCell(0);
  27. cell.setCellValue("Honda");
  28. wb.write(file);
  29. if(wb!=null) {
  30. wb.close();
  31. }
  32. file.close();
  33. System.out.println("It is done!");
  34. }
  35. }
Add Comment
Please, Sign In to add comment