List of usage examples for org.apache.poi.xssf.usermodel XSSFRow createCell
@Override public XSSFCell createCell(int columnIndex, CellType type)
From source file:com.dao.DatabaseDao.java
public static void exportDB(String destpath) { try {// www . j a v a 2 s . c om DB db = new DB(); Connection c = db.getConnection(); Statement st = c.createStatement(); ResultSet rs = st.executeQuery("SELECT * FROM EMPLOYEE_INFO"); XSSFWorkbook wb = new XSSFWorkbook(); XSSFSheet sheet = wb.createSheet("EmployeeInfo"); XSSFRow row = sheet.createRow(0); row.createCell(0, CellType.STRING).setCellValue("ID"); row.createCell(1, CellType.STRING).setCellValue("NAME"); row.createCell(2, CellType.STRING).setCellValue("RECEIPT_NO"); row.createCell(3, CellType.STRING).setCellValue("ENTRY_DATE"); row.createCell(4, CellType.STRING).setCellValue("SUB_RATE"); row.createCell(5, CellType.STRING).setCellValue("JAN"); row.createCell(6, CellType.STRING).setCellValue("FEB"); row.createCell(7, CellType.STRING).setCellValue("MAR"); row.createCell(8, CellType.STRING).setCellValue("APR"); row.createCell(9, CellType.STRING).setCellValue("MAY"); row.createCell(10, CellType.STRING).setCellValue("JUN"); row.createCell(11, CellType.STRING).setCellValue("JUL"); row.createCell(12, CellType.STRING).setCellValue("AUG"); row.createCell(13, CellType.STRING).setCellValue("SEP"); row.createCell(14, CellType.STRING).setCellValue("OCT"); row.createCell(15, CellType.STRING).setCellValue("NOV"); row.createCell(16, CellType.STRING).setCellValue("DECB"); row.createCell(17, CellType.STRING).setCellValue("TOTAL"); row.createCell(18, CellType.STRING).setCellValue("REMARK"); row.createCell(19, CellType.STRING).setCellValue("SECTOR"); row.createCell(20, CellType.STRING).setCellValue("SUB_FROM"); row.createCell(21, CellType.STRING).setCellValue("SUB_TO"); row.createCell(22, CellType.STRING).setCellValue("PLACE"); int i = 1; while (rs.next()) { row = sheet.createRow(i); row.createCell(0, CellType.STRING).setCellValue(rs.getLong("ID")); row.createCell(1, CellType.STRING).setCellValue(rs.getString("NAME")); row.createCell(2, CellType.STRING).setCellValue(rs.getLong("RECEIPT_NO")); row.createCell(3, CellType.STRING).setCellValue(rs.getDate("ENTRY_DATE")); row.createCell(4, CellType.STRING).setCellValue(rs.getInt("SUB_RATE")); row.createCell(5, CellType.STRING).setCellValue(rs.getInt("JAN")); row.createCell(6, CellType.STRING).setCellValue(rs.getInt("FEB")); row.createCell(7, CellType.STRING).setCellValue(rs.getInt("MAR")); row.createCell(8, CellType.STRING).setCellValue(rs.getInt("APR")); row.createCell(9, CellType.STRING).setCellValue(rs.getInt("MAY")); row.createCell(10, CellType.STRING).setCellValue(rs.getInt("JUN")); row.createCell(11, CellType.STRING).setCellValue(rs.getInt("JUL")); row.createCell(12, CellType.STRING).setCellValue(rs.getInt("AUG")); row.createCell(13, CellType.STRING).setCellValue(rs.getInt("SEP")); row.createCell(14, CellType.STRING).setCellValue(rs.getInt("OCT")); row.createCell(15, CellType.STRING).setCellValue(rs.getInt("NOV")); row.createCell(16, CellType.STRING).setCellValue(rs.getInt("DECB")); row.createCell(17, CellType.STRING).setCellValue(rs.getLong("TOTAL")); row.createCell(18, CellType.STRING).setCellValue(rs.getString("REMARK")); row.createCell(19, CellType.STRING).setCellValue(rs.getString("SECTOR")); row.createCell(20, CellType.STRING).setCellValue(rs.getString("SUB_FROM")); row.createCell(21, CellType.STRING).setCellValue(rs.getString("SUB_TO")); row.createCell(22, CellType.STRING).setCellValue(rs.getString("PLACE")); i++; } Calendar cal = Calendar.getInstance(); String filename = "BMSBackup_" + cal.get(Calendar.DAY_OF_MONTH) + "_" + (cal.get(Calendar.MONTH) + 1) + "_" + cal.get(Calendar.YEAR) + ".xlsx"; FileOutputStream fout = new FileOutputStream(destpath + "\\" + filename); wb.write(fout); fout.flush(); fout.close(); } catch (Exception e) { e.printStackTrace(); JOptionPane.showMessageDialog(null, "Database Exporting Error..." + e.getMessage(), "Error Message", JOptionPane.ERROR_MESSAGE); } }
From source file:control.DocFile.java
public void setProductToFile(HangHoa hangHoa) { XSSFRow row = sheet.createRow(this.laySoRecordTrongSheet() + 2); row.createCell(SP_MA_HANG_HOA, CellType.STRING).setCellValue(hangHoa.getMaHangHoa()); row.createCell(SP_TEN_HANG_HOA, CellType.STRING).setCellValue(hangHoa.getTenHangHoa()); row.createCell(SP_NHOM_HANG_HOA, CellType.STRING).setCellValue(hangHoa.getNhomHangHoa()); row.createCell(SP_GIA_VON, CellType.STRING).setCellValue(hangHoa.getGiaVon()); row.createCell(SP_GIA_BAN, CellType.STRING).setCellValue(hangHoa.getGiaBan()); row.createCell(SP_TON_KHO, CellType.STRING).setCellValue(hangHoa.getTonKho()); row.createCell(SP_DINH_MUC_TON_IT_NHAT, CellType.STRING).setCellValue(hangHoa.getDinhMucTonItNhat()); row.createCell(SP_DINH_MUC_TON_NHIEU_NHAT, CellType.STRING).setCellValue(hangHoa.getDinhMucTonNhieuNhat()); }
From source file:org.azkfw.doclet.jaxrs.writer.JAXRSXlsxDocletWriter.java
License:Apache License
private void printSheet(final XSSFWorkbook wb, final XSSFSheet sheet, final APIModel api) { //////////////////////////////////////////////////// XSSFRow row = null; XSSFCell cell = null;// ww w. j a v a 2 s .c o m //////////////////////////////////////////////////// row = sheet.createRow(1); ////////////////////////// cell = row.createCell(1, Cell.CELL_TYPE_STRING); cell.setCellValue("??"); cell = row.createCell(5, Cell.CELL_TYPE_STRING); cell.setCellValue(s(api.getName())); cell = row.createCell(22, Cell.CELL_TYPE_STRING); cell.setCellValue(""); cell = row.createCell(25, Cell.CELL_TYPE_STRING); cell.setCellValue("TUF-8"); row = sheet.createRow(2); ////////////////////////// cell = row.createCell(1, Cell.CELL_TYPE_STRING); cell.setCellValue("URL"); cell = row.createCell(5, Cell.CELL_TYPE_STRING); cell.setCellValue(s(api.getPath())); cell = row.createCell(15, Cell.CELL_TYPE_STRING); cell.setCellValue(""); cell = row.createCell(18, Cell.CELL_TYPE_STRING); cell.setCellValue(""); }
From source file:org.azkfw.doclet.jaxrs.writer.JAXRSXlsxDocletWriter.java
License:Apache License
private void printSheet(final XSSFWorkbook wb, final XSSFSheet sheet, final List<APIModel> apis) { XSSFCell cell = null;/*from w w w . j a v a 2 s. c om*/ XSSFRow row = null; //////////////////////////////////////////////////// XSSFFont fontBold = wb.createFont(); fontBold.setBold(true); CellStyle styleHeader = wb.createCellStyle(); styleHeader.setFillPattern(CellStyle.SOLID_FOREGROUND); styleHeader.setFillForegroundColor(IndexedColors.SKY_BLUE.getIndex()); styleHeader.setFont(fontBold); styleHeader.setBorderTop(CellStyle.BORDER_THIN); styleHeader.setBorderLeft(CellStyle.BORDER_THIN); styleHeader.setBorderRight(CellStyle.BORDER_THIN); styleHeader.setBorderBottom(CellStyle.BORDER_DOUBLE); row = sheet.createRow(0); ////////////////////////// cell = row.createCell(1, Cell.CELL_TYPE_STRING); CellStyle style1 = wb.createCellStyle(); style1.setFont(fontBold); cell.setCellStyle(style1); cell.setCellValue("I/F (API) "); row = sheet.createRow(1); ////////////////////////// cell = row.createCell(1, Cell.CELL_TYPE_STRING); cell.setCellValue("API???"); row = sheet.createRow(4); ////////////////////////// cell = row.createCell(1, Cell.CELL_TYPE_STRING); cell.setCellValue("ID"); cell.setCellStyle(styleHeader); cell = row.createCell(2, Cell.CELL_TYPE_STRING); cell.setCellValue("Group"); cell.setCellStyle(styleHeader); cell = row.createCell(3, Cell.CELL_TYPE_STRING); cell.setCellValue("Name"); cell.setCellStyle(styleHeader); cell = row.createCell(4, Cell.CELL_TYPE_STRING); cell.setCellValue("Comment"); cell.setCellStyle(styleHeader); int offsetRow = 5; int offsetCol = 1; for (int i = 0; i < apis.size(); i++) { APIModel api = apis.get(i); row = sheet.createRow(offsetRow + i); cell = row.createCell(offsetCol + 0, Cell.CELL_TYPE_STRING); cell.setCellValue(s(api.getId())); cell = row.createCell(offsetCol + 2, Cell.CELL_TYPE_STRING); cell.setCellValue(s(api.getName())); cell = row.createCell(offsetCol + 3, Cell.CELL_TYPE_STRING); cell.setCellValue(s(api.getComment())); } }
From source file:org.azkfw.document.database.xlsx.XLSXWriter.java
License:Apache License
private XSSFCell createCell(final int col, final int size, final String text, final XSSFCellStyle style, final Hyperlink link, final XSSFRow row) { XSSFCell cell = null;//from w w w.j a va 2s .c o m for (int i = size - 1; i >= 0; i--) { cell = row.createCell(col + i, Cell.CELL_TYPE_STRING); if (null != style) { cell.setCellStyle(style); } if (null != link) { cell.setHyperlink(link); } } cell.setCellValue(s(text)); return cell; }