List of usage examples for org.apache.poi.hssf.usermodel HSSFRow createCell
@Override public HSSFCell createCell(int column)
From source file:dao.ExportacaoParaExcel.java
private void AdicionaLinha(HSSFRow row, int coluna, Date valor) { //Linha alimenta novo valor row.createCell(coluna).setCellValue(valor); firstSheet.autoSizeColumn(coluna);// www . j a v a2 s . c om }
From source file:dao.ExportacaoParaExcel.java
private void AdicionaLinha(HSSFRow row, int coluna, int valor) { //Linha alimenta novo valor row.createCell(coluna).setCellValue(valor); firstSheet.autoSizeColumn(coluna);/* w ww . ja v a2 s.co m*/ }
From source file:dao.ExportacaoParaExcel.java
private void AdicionaColunaCabecalho(int coluna, Date valor) { Calendar calendar = Calendar.getInstance(); calendar.setTime(valor);//from ww w . ja v a 2 s .c o m SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); String data = sdf.format(calendar.getTime()); //Linha alimenta novo valor HSSFRow rowcabec = firstSheet.getRow(linhaCabecalho); //Descricao da operacao rowcabec.createCell(coluna).setCellValue(data); firstSheet.autoSizeColumn(coluna); }
From source file:data.pkg.ReadWriteExcelFile.java
public static void writeXLSFile(String fileName, Data data) throws IOException { String excelFileName = fileName;//name of excel file String sheetName = "Sheet1";//name of sheet HSSFWorkbook wb = new HSSFWorkbook(); HSSFSheet sheet = wb.createSheet(sheetName); //iterating r number of rows for (int r = 0; r < data.getLength(); r++) { HSSFRow row = sheet.createRow(r); //iterating c number of columns for (int c = 0; c < 2; c++) { if (r == 0 && c == 0) { HSSFCell cell = row.createCell(c); cell.setCellValue("Deslocamento"); }/*from w w w . ja v a 2 s . c o m*/ if (r == 0 && c == 1) { HSSFCell cell = row.createCell(c); cell.setCellValue("Fora"); } if (r > 0 && c == 0) { HSSFCell cell = row.createCell(c); cell.setCellValue(data.getDeslocamento(r - 1)); } if (r > 0 && c == 1) { HSSFCell cell = row.createCell(c); cell.setCellValue(data.getForca(r - 1)); } } } FileOutputStream fileOut = new FileOutputStream(excelFileName); //write this workbook to an Outputstream. wb.write(fileOut); fileOut.flush(); fileOut.close(); }
From source file:data.services.BaseParamService.java
public HSSFWorkbook getXls() { Logger log = Logger.getLogger(this.getClass()); try {/* ww w.ja va 2s . c o m*/ HSSFWorkbook workbook = new HSSFWorkbook(); List<BaseParam> bpList = getParams(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("UID"); rowhead.createCell(1).setCellValue("????"); rowhead.createCell(2).setCellValue(""); rowhead.createCell(3).setCellValue("??"); rowhead.createCell(4).setCellValue("??"); rowhead.createCell(5).setCellValue("??"); rowhead.createCell(6).setCellValue("??"); rowhead.createCell(7).setCellValue("?"); rowhead.createCell(8).setCellValue("?"); int n = 1; if (!bpList.isEmpty()) { for (BaseParam bp : bpList) { HSSFRow rowbody = sheet.createRow((short) n); rowbody.createCell(0).setCellValue(StringAdapter.getString(bp.getUid().trim())); rowbody.createCell(1).setCellValue(StringAdapter.getString(bp.getName())); rowbody.createCell(2).setCellValue(StringAdapter.getString(bp.getParamType().getName())); rowbody.createCell(3).setCellValue(StringAdapter.getString(bp.getStaticType().getName())); rowbody.createCell(4).setCellValue(StringAdapter.getString(getPercentParamsAsString(bp))); rowbody.createCell(5).setCellValue(StringAdapter.getString(bp.getRadical())); rowbody.createCell(6).setCellValue(StringAdapter.getString(bp.getAudial())); rowbody.createCell(7).setCellValue(StringAdapter.getString(bp.getVisual())); rowbody.createCell(8).setCellValue(StringAdapter.getString(bp.getKinestet())); n++; } ; } return workbook; } catch (Exception e) { log.warn("HSSFWorkbook.getXls()", e); } return null; }
From source file:data.services.CarCompletionOptionService.java
public HSSFWorkbook getXls() { Logger log = Logger.getLogger(this.getClass()); try {/* w w w . j ava 2 s.co m*/ HSSFWorkbook workbook = new HSSFWorkbook(); List<CarCompletionOption> oblist = carCompletionOptionDao.getAllAsc(); HSSFSheet sheet = workbook.createSheet("FirsSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("ID"); rowhead.createCell(1).setCellValue("TITLE"); rowhead.createCell(2).setCellValue(" "); rowhead.createCell(3).setCellValue("UID"); rowhead.createCell(4).setCellValue(""); rowhead.createCell(5).setCellValue(""); rowhead.createCell(6).setCellValue(""); rowhead.createCell(7).setCellValue("?"); rowhead.createCell(8).setCellValue(""); rowhead.createCell(9).setCellValue("?"); int n = 1; if (!oblist.isEmpty()) { for (CarCompletionOption ob : oblist) { HSSFRow rowbody = sheet.createRow((short) n); rowbody.createCell(0).setCellValue(StringAdapter.getString(ob.getCcoId())); rowbody.createCell(1).setCellValue(StringAdapter.getString(ob.getTitle())); rowbody.createCell(2).setCellValue(StringAdapter.getString(ob.getTitleFull())); rowbody.createCell(3).setCellValue(StringAdapter.getString(ob.getUid())); rowbody.createCell(4) .setCellValue(StringAdapter.getString(ob.getParamValue()).replace(".", ",")); rowbody.createCell(5).setCellValue(StringAdapter.getString(ob.getPercentValue())); rowbody.createCell(6).setCellValue(StringAdapter.getString(ob.getRadical())); rowbody.createCell(7).setCellValue(StringAdapter.getString(ob.getAudial())); rowbody.createCell(8).setCellValue(StringAdapter.getString(ob.getVisual())); rowbody.createCell(9).setCellValue(StringAdapter.getString(ob.getKinestet())); n++; } } return workbook; } catch (Exception e) { log.warn("HSSFWorkbook.getXls()", e); } return null; }
From source file:data.services.CarOptionValueService.java
public HSSFWorkbook getXls() { Logger log = Logger.getLogger(this.getClass()); try {// w w w.j av a 2 s. com HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("ID"); rowhead.createCell(1).setCellValue("UID"); rowhead.createCell(2).setCellValue("??"); rowhead.createCell(3).setCellValue("??"); rowhead.createCell(4).setCellValue(""); rowhead.createCell(5).setCellValue(""); rowhead.createCell(6).setCellValue(""); rowhead.createCell(7).setCellValue("?"); rowhead.createCell(8).setCellValue(""); rowhead.createCell(9).setCellValue("?"); List<CarOptionValue> covlist = getUniqueOptionNames(Long.valueOf(0)); int n = 1; if (!covlist.isEmpty()) { for (CarOptionValue cov : covlist) { HSSFRow rowbody = sheet.createRow((short) n); String desc = cov.getDescription(); if (desc.equals("")) { desc = " ??"; } rowbody.createCell(0).setCellValue(StringAdapter.getString(cov.getId())); rowbody.createCell(1).setCellValue(StringAdapter.getString(cov.getCCO().getUid())); rowbody.createCell(2).setCellValue(StringAdapter.getString(cov.getCCO().getTitle())); rowbody.createCell(3).setCellValue(desc); rowbody.createCell(4).setCellValue(StringAdapter.getString(cov.getRadical())); rowbody.createCell(5) .setCellValue(StringAdapter.getString(cov.getParamValue()).replace(".", ",")); rowbody.createCell(6).setCellValue(StringAdapter.getString(cov.getPercentValue())); rowbody.createCell(7).setCellValue(StringAdapter.getString(cov.getAudial())); rowbody.createCell(8).setCellValue(StringAdapter.getString(cov.getVisual())); rowbody.createCell(9).setCellValue(StringAdapter.getString(cov.getKinestet())); n++; } ; } return workbook; } catch (Exception e) { log.warn("HSSFWorkbook.getXls()", e); } return null; }
From source file:data.services.CarPropertyService.java
public HSSFWorkbook getXls() { Logger log = Logger.getLogger(this.getClass()); try {/* w w w . j av a2 s. c o m*/ HSSFWorkbook workbook = new HSSFWorkbook(); List<CarProperty> oblist = carPropertyDao.getAllAsc(); HSSFSheet sheet = workbook.createSheet("FirsSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("ID"); rowhead.createCell(1).setCellValue("TITLE"); rowhead.createCell(2).setCellValue(""); rowhead.createCell(3).setCellValue("UID"); rowhead.createCell(4).setCellValue(""); rowhead.createCell(5).setCellValue(""); rowhead.createCell(6).setCellValue(""); int n = 1; if (!oblist.isEmpty()) { for (CarProperty ob : oblist) { HSSFRow rowbody = sheet.createRow((short) n); rowbody.createCell(0).setCellValue(StringAdapter.getString(ob.getCpId())); rowbody.createCell(1).setCellValue(StringAdapter.getString(ob.getTitle())); rowbody.createCell(2).setCellValue(StringAdapter.getString(ob.getCPG().getTitle())); rowbody.createCell(3).setCellValue(StringAdapter.getString(ob.getUid())); rowbody.createCell(4) .setCellValue(StringAdapter.getString(ob.getParamValue()).replace(".", ",")); rowbody.createCell(5).setCellValue(StringAdapter.getString(ob.getPercentValue())); rowbody.createCell(6).setCellValue(StringAdapter.getString(ob.getRadical())); n++; } ; } return workbook; } catch (Exception e) { log.warn("HSSFWorkbook.getXls()", e); } return null; }
From source file:data.services.ColorGroupService.java
public HSSFWorkbook getXls() { Logger log = Logger.getLogger(this.getClass()); try {/*from ww w.j a v a 2s.co m*/ HSSFWorkbook workbook = new HSSFWorkbook(); List<ColorGroup> oblist = colorGroupDao.getAllAsc(); HSSFSheet sheet = workbook.createSheet("FirsSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("ID"); rowhead.createCell(1).setCellValue("TITLE"); rowhead.createCell(2).setCellValue("????"); rowhead.createCell(3).setCellValue("UID"); rowhead.createCell(4).setCellValue(""); rowhead.createCell(5).setCellValue(""); rowhead.createCell(6).setCellValue(""); int n = 1; if (!oblist.isEmpty()) { for (ColorGroup ob : oblist) { HSSFRow rowbody = sheet.createRow((short) n); rowbody.createCell(0).setCellValue(StringAdapter.getString(ob.getColorGroupId())); rowbody.createCell(1).setCellValue(StringAdapter.getString(ob.getName())); rowbody.createCell(2).setCellValue(StringAdapter.getString(ob.getTitle())); rowbody.createCell(3).setCellValue(StringAdapter.getString(ob.getUid())); rowbody.createCell(4).setCellValue(StringAdapter.getString(ob.getParamValue())); rowbody.createCell(5).setCellValue(StringAdapter.getString(ob.getPercentValue())); rowbody.createCell(6).setCellValue(StringAdapter.getString(ob.getRadical())); n++; } ; } return workbook; } catch (Exception e) { log.warn("HSSFWorkbook.getXls()", e); } return null; }
From source file:data.services.ColorService.java
public HSSFWorkbook getXls() { Logger log = Logger.getLogger(this.getClass()); try {/*from www.j a v a 2s. c om*/ HSSFWorkbook workbook = new HSSFWorkbook(); List<Color> oblist = colorDao.getAllAsc(); HSSFSheet sheet = workbook.createSheet("FirstSheet"); HSSFRow rowhead = sheet.createRow((short) 0); rowhead.createCell(0).setCellValue("ID"); rowhead.createCell(1).setCellValue("TITLE"); rowhead.createCell(2).setCellValue("????"); rowhead.createCell(3).setCellValue("UID"); rowhead.createCell(4).setCellValue(""); rowhead.createCell(5).setCellValue(""); rowhead.createCell(6).setCellValue(""); rowhead.createCell(7).setCellValue("?"); rowhead.createCell(8).setCellValue(""); rowhead.createCell(9).setCellValue("?"); int n = 1; if (!oblist.isEmpty()) { for (Color ob : oblist) { HSSFRow rowbody = sheet.createRow((short) n); rowbody.createCell(0).setCellValue(StringAdapter.getString(ob.getColorId())); rowbody.createCell(1).setCellValue(StringAdapter.getString(ob.getName())); rowbody.createCell(2).setCellValue(StringAdapter.getString(ob.getTitle())); rowbody.createCell(3).setCellValue(StringAdapter.getString(ob.getUid())); rowbody.createCell(4) .setCellValue(StringAdapter.getString(ob.getParamValue()).replace(".", ",")); rowbody.createCell(5).setCellValue(StringAdapter.getString(ob.getPercentValue())); rowbody.createCell(6).setCellValue(StringAdapter.getString(ob.getRadical())); rowbody.createCell(7).setCellValue(StringAdapter.getString(ob.getAudial())); rowbody.createCell(8).setCellValue(StringAdapter.getString(ob.getVisual())); rowbody.createCell(9).setCellValue(StringAdapter.getString(ob.getKinestet())); n++; } ; } return workbook; } catch (Exception e) { log.warn("HSSFWorkbook.getXls()", e); } return null; }