List of usage examples for org.apache.poi.ss.usermodel Sheet createRow
Row createRow(int rownum);
From source file:com.solidmaps.webapp.report.TimesheetDemo.java
License:Apache License
public void main(String[] args) throws Exception { Workbook wb = new HSSFWorkbook(); Map<String, CellStyle> styles = createStyles(wb); Sheet sheet = wb.createSheet("Timesheet"); PrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(true);/*from w ww .ja v a 2 s. c om*/ sheet.setFitToPage(true); sheet.setHorizontallyCenter(true); //title row Row titleRow = sheet.createRow(0); titleRow.setHeightInPoints(45); Cell titleCell = titleRow.createCell(0); titleCell.setCellValue("Weekly Timesheet"); titleCell.setCellStyle(styles.get("title")); sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$L$1")); //header row Row headerRow = sheet.createRow(1); headerRow.setHeightInPoints(40); Cell headerCell; for (int i = 0; i < titles.length; i++) { headerCell = headerRow.createCell(i); headerCell.setCellValue(titles[i]); headerCell.setCellStyle(styles.get("header")); } int rownum = 2; for (int i = 0; i < 10; i++) { Row row = sheet.createRow(rownum++); for (int j = 0; j < titles.length; j++) { Cell cell = row.createCell(j); if (j == 9) { //the 10th cell contains sum over week days, e.g. SUM(C3:I3) String ref = "C" + rownum + ":I" + rownum; cell.setCellFormula("SUM(" + ref + ")"); cell.setCellStyle(styles.get("formula")); } else if (j == 11) { cell.setCellFormula("J" + rownum + "-K" + rownum); cell.setCellStyle(styles.get("formula")); } else { cell.setCellStyle(styles.get("cell")); } } } //row with totals below Row sumRow = sheet.createRow(rownum++); sumRow.setHeightInPoints(35); Cell cell; cell = sumRow.createCell(0); cell.setCellStyle(styles.get("formula")); cell = sumRow.createCell(1); cell.setCellValue("Total Hrs:"); cell.setCellStyle(styles.get("formula")); for (int j = 2; j < 12; j++) { cell = sumRow.createCell(j); String ref = (char) ('A' + j) + "3:" + (char) ('A' + j) + "12"; cell.setCellFormula("SUM(" + ref + ")"); if (j >= 9) cell.setCellStyle(styles.get("formula_2")); else cell.setCellStyle(styles.get("formula")); } rownum++; sumRow = sheet.createRow(rownum++); sumRow.setHeightInPoints(25); cell = sumRow.createCell(0); cell.setCellValue("Total Regular Hours"); cell.setCellStyle(styles.get("formula")); cell = sumRow.createCell(1); cell.setCellFormula("L13"); cell.setCellStyle(styles.get("formula_2")); sumRow = sheet.createRow(rownum++); sumRow.setHeightInPoints(25); cell = sumRow.createCell(0); cell.setCellValue("Total Overtime Hours"); cell.setCellStyle(styles.get("formula")); cell = sumRow.createCell(1); cell.setCellFormula("K13"); cell.setCellStyle(styles.get("formula_2")); //set sample data for (int i = 0; i < sample_data.length; i++) { Row row = sheet.getRow(2 + i); for (int j = 0; j < sample_data[i].length; j++) { if (sample_data[i][j] == null) continue; if (sample_data[i][j] instanceof String) { row.getCell(j).setCellValue((String) sample_data[i][j]); } else { row.getCell(j).setCellValue((Double) sample_data[i][j]); } } } //finally set column widths, the width is measured in units of 1/256th of a character width sheet.setColumnWidth(0, 30 * 256); //30 characters wide for (int i = 2; i < 9; i++) { sheet.setColumnWidth(i, 6 * 256); //6 characters wide } sheet.setColumnWidth(10, 10 * 256); //10 characters wide // Write the output to a file String file = "/home/brunorocca/Desktop/mapa_teste.xls"; if (wb instanceof XSSFWorkbook) file += "x"; FileOutputStream out = new FileOutputStream(file); wb.write(out); out.close(); }
From source file:com.springapp.mvc.BusinessPlan.java
License:Apache License
public static void main(String[] args) throws Exception { Workbook wb;/* w w w .j a v a2s. c o m*/ if (args.length > 0 && args[0].equals("-xls")) wb = new HSSFWorkbook(); else wb = new XSSFWorkbook(); Map<String, CellStyle> styles = createStyles(wb); Sheet sheet = wb.createSheet("Business Plan"); //turn off gridlines sheet.setDisplayGridlines(false); sheet.setPrintGridlines(false); sheet.setFitToPage(true); sheet.setHorizontallyCenter(true); PrintSetup printSetup = sheet.getPrintSetup(); printSetup.setLandscape(true); //the following three statements are required only for HSSF sheet.setAutobreaks(true); printSetup.setFitHeight((short) 1); printSetup.setFitWidth((short) 1); //the header row: centered text in 48pt font Row headerRow = sheet.createRow(0); headerRow.setHeightInPoints(12.75f); for (int i = 0; i < titles.length; i++) { Cell cell = headerRow.createCell(i); cell.setCellValue(titles[i]); cell.setCellStyle(styles.get("header")); } //columns for 11 weeks starting from 9-Jul Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); //calendar.setTime(fmt.parse("9-11")); calendar.set(Calendar.YEAR, year); for (int i = 0; i < 11; i++) { Cell cell = headerRow.createCell(titles.length + i); cell.setCellValue(calendar); cell.setCellStyle(styles.get("header_date")); calendar.roll(Calendar.WEEK_OF_YEAR, true); } //freeze the first row sheet.createFreezePane(0, 1); Row row; Cell cell; int rownum = 1; for (int i = 0; i < data.length; i++, rownum++) { row = sheet.createRow(rownum); if (data[i] == null) continue; for (int j = 0; j < data[i].length; j++) { cell = row.createCell(j); String styleName; boolean isHeader = i == 0 || data[i - 1] == null; switch (j) { case 0: if (isHeader) { styleName = "cell_b"; cell.setCellValue(Double.parseDouble(data[i][j])); } else { styleName = "cell_normal"; cell.setCellValue(data[i][j]); } break; case 1: if (isHeader) { styleName = i == 0 ? "cell_h" : "cell_bb"; } else { styleName = "cell_indented"; } cell.setCellValue(data[i][j]); break; case 2: styleName = isHeader ? "cell_b" : "cell_normal"; cell.setCellValue(data[i][j]); break; case 3: styleName = isHeader ? "cell_b_centered" : "cell_normal_centered"; cell.setCellValue(Integer.parseInt(data[i][j])); break; case 4: { //calendar.setTime(fmt.parse(data[i][j])); calendar.set(Calendar.YEAR, year); cell.setCellValue(calendar); styleName = isHeader ? "cell_b_date" : "cell_normal_date"; break; } case 5: { int r = rownum + 1; String fmla = "IF(AND(D" + r + ",E" + r + "),E" + r + "+D" + r + ",\"\")"; cell.setCellFormula(fmla); styleName = isHeader ? "cell_bg" : "cell_g"; break; } default: styleName = data[i][j] != null ? "cell_blue" : "cell_normal"; } cell.setCellStyle(styles.get(styleName)); } } //group rows for each phase, row numbers are 0-based sheet.groupRow(4, 6); sheet.groupRow(9, 13); sheet.groupRow(16, 18); //set column widths, the width is measured in units of 1/256th of a character width sheet.setColumnWidth(0, 256 * 6); sheet.setColumnWidth(1, 256 * 33); sheet.setColumnWidth(2, 256 * 20); sheet.setZoom(3, 4); // Write the output to a file String file = "businessplan.xls"; if (wb instanceof XSSFWorkbook) file += "x"; FileOutputStream out = new FileOutputStream(file); wb.write(out); out.close(); }
From source file:com.stam.excellatin.ExcelLatin.java
public static void main(String[] args) { List<String> options = new ArrayList<>(); int startIndex = 0; for (String arg : args) { if (validOptions.contains(arg)) { options.add(arg);//from w w w. jav a 2 s.c om startIndex++; } } if (args[0].equals("-h") || args.length < 3) { System.out.println("usage: ExcelLatin [options] filenameIn filenameOut columnNames..."); System.out.println("options:"); System.out.println("\t-L\tto Latin (default)"); System.out.println("\t-G\tto Greek"); System.out.println("\t-d\tdon't deaccent"); System.out.println("\t-h\thelp"); } else { boolean greekToLatin = false; boolean latinToGreek = false; Transliterator transliterator = null; if ((!options.contains("-L") && !options.contains("-G")) || options.contains("-L")) { transliterator = Transliterator.getInstance("Greek-Latin/UNGEGN"); System.out.println("\nTransliterating Greek to Latin"); greekToLatin = true; } else if (options.contains("-G")) { transliterator = Transliterator.getInstance("Latin-Greek/UNGEGN"); System.out.println("\nTransliterating Latin to Greek"); latinToGreek = true; } if (transliterator == null) { System.out.println("Not a valid option for the transliteration language"); return; } boolean deAccent = true; if (options.contains("-d")) { deAccent = false; System.out.println("Will not deaccent"); } String fileNameIn = args[startIndex]; String fileNameOut = args[startIndex + 1]; List<String> columnNames = new ArrayList<>(); System.out.println("\nColumns to transliterate\n---------------------------"); for (int i = startIndex + 2; i < args.length; i++) { columnNames.add(args[i]); System.out.println(args[i]); } System.out.println("\n"); try { File file = new File(fileNameIn); if (!file.exists()) { System.out.println("The file " + fileNameIn + " was not found"); return; } Map<String, String> mapTransformations = new HashMap<>(); Scanner sc = new Scanner(new FileReader("map.txt")); while (sc.hasNextLine()) { String greekEntry = sc.next(); String latinEntry = sc.next(); if (greekToLatin) { mapTransformations.put(greekEntry, latinEntry); } else if (latinToGreek) { mapTransformations.put(latinEntry, greekEntry); } } DataFormatter formatter = new DataFormatter(); Workbook wb = WorkbookFactory.create(file); Workbook newWb = null; if (wb instanceof HSSFWorkbook) { newWb = new HSSFWorkbook(); } else if (wb instanceof XSSFWorkbook) { newWb = new XSSFWorkbook(); } FileOutputStream fileOut = new FileOutputStream(fileNameOut); if (newWb != null) { Sheet sheetOut = newWb.createSheet(); Sheet sheet = wb.getSheetAt(0); List<Integer> idxs = new ArrayList<>(); Row row = sheet.getRow(0); for (Cell cell : row) { String cellVal = formatter.formatCellValue(cell); if (cellVal == null || cellVal.trim().equals("")) { break; } if (columnNames.contains(cell.getStringCellValue())) { idxs.add(cell.getColumnIndex()); } } for (Row rowIn : sheet) { Row rowOut = sheetOut.createRow(rowIn.getRowNum()); if (rowIn.getRowNum() == 0) { for (Cell cell : rowIn) { cell.setCellType(Cell.CELL_TYPE_STRING); Cell cellOut = rowOut.createCell(cell.getColumnIndex()); cellOut.setCellValue(cell.getStringCellValue()); } } else { for (Cell cell : rowIn) { cell.setCellType(Cell.CELL_TYPE_STRING); String cellVal = formatter.formatCellValue(cell); String cellNewVal = cellVal; if (idxs.contains(cell.getColumnIndex()) && cellVal != null) { if (mapTransformations.containsKey(cellVal)) { cellNewVal = mapTransformations.get(cellVal); } else { if (deAccent) { cellNewVal = deAccent(transliterator.transform(cellVal)); } else { cellNewVal = transliterator.transform(cellVal); } } } Cell cellOut = rowOut.createCell(cell.getColumnIndex()); cellOut.setCellValue(cellNewVal); } } } System.out.println("Finished!"); newWb.write(fileOut); fileOut.close(); } } catch (IOException | InvalidFormatException ex) { Logger.getLogger(ExcelLatin.class.toString()).log(Level.SEVERE, null, ex); } } }
From source file:com.suomi.carinsurance.export.excel.ExcelService.java
License:Open Source License
/** * /*from ww w . j a va2 s .c o m*/ * * @param outputStream ? * @param config ? * @param data ? * @param elementClass */ public <T> void export(OutputStream outputStream, ExcelWorkbook config, List<T> data, Class<T> elementClass) { if (outputStream == null) { throw new RuntimeException("Excel outputStream is null"); } if (config == null) { throw new RuntimeException("Excel config is null"); } if (data == null) { return; } try { // ? Workbook workbook = new HSSFWorkbook(); // ? List<ExcelSheet> sheetConfigList = config.getSheetList(); if (sheetConfigList != null && sheetConfigList.size() > 0) { for (ExcelSheet sheetConfig : sheetConfigList) { Sheet sheet = workbook.createSheet(sheetConfig.getName()); // ? List<ExcelField> fieldConfigList = sheetConfig.getFieldList(); if (fieldConfigList != null && fieldConfigList.size() > 0) { int rowIndex = 0; int colIndex = 0; List<String> javaFieldList = new ArrayList<String>(); // ? Row titleRow = sheet.createRow(rowIndex); for (ExcelField fieldConfig : fieldConfigList) { if (fieldConfig != null && fieldConfig.isExport() //&& StringUtil.isNotBlank(fieldConfig.getExcelName()) && StringUtil.isNotBlank(fieldConfig.getJavaName())) { String excelName = fieldConfig.getExcelName(); if (StringUtil.isBlank(excelName)) { Field field = ReflectUtil.getField(elementClass, fieldConfig.getJavaName()); com.suomi.carinsurance.annotation.ExcelField excelField = field .getAnnotation(com.suomi.carinsurance.annotation.ExcelField.class); excelName = excelField.name(); } if (StringUtil.isBlank(excelName)) { continue; } titleRow.createCell(colIndex).setCellValue(excelName); javaFieldList.add(fieldConfig.getJavaName()); colIndex++; } } // ?? if (data.size() < 1) { break; } for (T item : data) { if (item == null) { continue; } rowIndex++; colIndex = 0; Row dataRow = sheet.createRow(rowIndex); for (String javaField : javaFieldList) { Cell dataCell = dataRow.createCell(colIndex); Object fieldValue = ReflectUtil.getFieldValue(item, javaField); if (fieldValue instanceof Boolean) { dataCell.setCellValue((boolean) fieldValue); } else if (fieldValue instanceof Number) { dataCell.setCellValue(((Number) fieldValue).doubleValue()); } else if (fieldValue instanceof BigDecimal) { dataCell.setCellValue(((BigDecimal) fieldValue).doubleValue()); } else if (fieldValue instanceof Date) { dataCell.setCellValue((Date) fieldValue); } else if (fieldValue instanceof Calendar) { dataCell.setCellValue((Calendar) fieldValue); } else if (fieldValue instanceof String) { dataCell.setCellValue((String) fieldValue); } else { dataCell.setCellValue(""); } colIndex++; } } } } } workbook.write(outputStream); } catch (Exception e) { throw new RuntimeException(e); } finally { IOUtil.close(outputStream); } }
From source file:com.svi.main.logic.ExtractAndPrint.java
private void writeLogFile(List<Nodes> nodesHolder) { DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd HHmm"); Date date = new Date(); Sheet mainSheet;//from www . j a v a 2 s. c o m Sheet dataSheet; Sheet elementSheet; Row dataSheetRow; Row elementSheetRow; InputStream fis; XSSFWorkbook workbook; File outputPath = new File(logPath + "\\Logs"); File outputFile = new File(logPath + "\\Logs\\BPO KPI Report " + dateFormat.format(date) + ".xlsx"); // File name int dataSheetRowCount = 1; int elementSheetRowCount = 1; int totalElementException = 0; try { if (!Files.exists(outputPath.toPath())) { Files.createDirectories(outputPath.toPath()); } fis = ExtractAndPrint.class.getResourceAsStream("bpo_template.xlsx"); workbook = new XSSFWorkbook(fis); //Style for exception sheet XSSFCellStyle style = workbook.createCellStyle(); style.setFillBackgroundColor(IndexedColors.YELLOW.getIndex()); style.setFillPattern(CellStyle.SOLID_FOREGROUND); //Get data Sheet mainSheet = workbook.getSheetAt(0); writeProjectDetails(mainSheet); dataSheet = workbook.getSheetAt(4); dataSheetRow = dataSheet.createRow(0); elementSheet = workbook.getSheetAt(1); elementSheetRow = elementSheet.createRow(0); //Write excel headers writeDataSheetHeaders(dataSheetRow); writeElementSheetHeaders(elementSheetRow); //Set progress bar values progress = new AtomicInteger(0); total = new AtomicInteger(nodesHolder.size()); mf.setJprogressValues(total, progress); // Sort the nodes per Node ID Collections.sort(nodesHolder, new Comparator<Nodes>() { public int compare(Nodes o1, Nodes o2) { return o1.getNodeId().compareTo(o2.getNodeId()); } }); //Write Data Sheet for (Nodes node : nodesHolder) { mf.loader(); dataSheetRow = dataSheet.createRow(dataSheetRowCount++); writeDataSheet(node, dataSheetRow); } for (Nodes node : nodesHolder) { for (Elements e : node) { if ((e.getStatus().equalsIgnoreCase("COMPLETE") || e.getStatus().equalsIgnoreCase("PROCESSING")) && e.getTotalProcTime() > MAX_MINUTES_ELEMENT) { totalElementException++; } } } progress = new AtomicInteger(0); total = new AtomicInteger(totalElementException); mf.setJprogressValues(total, progress); //Write exception sheet for (Nodes node : nodesHolder) { for (Elements e : node) { if ((e.getStatus().equalsIgnoreCase("COMPLETE") || e.getStatus().equalsIgnoreCase("PROCESSING")) && e.getTotalProcTime() > MAX_MINUTES_ELEMENT) { elementSheetRow = elementSheet.createRow(elementSheetRowCount++); writeElementSheet(e, elementSheetRow); mf.elementLoader(); } } } XSSFFormulaEvaluator.evaluateAllFormulaCells((XSSFWorkbook) workbook); try (FileOutputStream outputStream = new FileOutputStream(outputFile)) { workbook.write(outputStream);//Write the Excel File outputStream.close(); } workbook.close(); fis.close(); mf.generateMessage(); } catch (Exception ex) { Logger.getLogger(ExtractAndPrint.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.swordlord.gozer.components.csv.GCsvList.java
License:Open Source License
private void createRows(Sheet sheet) { DataBindingMember dbMember = _obList.getDataBindingMember(); DataBindingContext dbc = getFrameExtension().getDataBindingContext(); DataBindingManager dbManager = dbc.getDataBindingManager(dbMember); List<DataRowBase> subList = null; String strOrdering = _obList.getOrdering(); if ((strOrdering != null) && (strOrdering.length() > 0)) { OrderingParam orderingParam = new OrderingParam(strOrdering, true, false); subList = dbManager.getRows(dbMember, orderingParam); } else {/* www. ja v a 2 s. c o m*/ subList = dbManager.getRows(dbMember); } if ((subList == null) || (subList.size() == 0)) { return; } int nColumns = 0; LinkedList<ObjectBase> children = _obList.getChildren(); if (children.size() > 0) { // TODO fix this hack nColumns = children.size(); } Iterator<DataRowBase> it = subList.iterator(); while (it.hasNext()) { Row row = sheet.createRow(sheet.getLastRowNum() + 1); DataRowBase dataRow = it.next(); for (int i = 0; i < nColumns; i++) { final ObjectBase child = children.get(i); Cell cell = row.createCell(i); if ((child.getClass().equals(GField.class)) || (child.getClass().equals(GCodeField.class))) { DataBinding dataBindingChild = child.getDataBinding(); Object oValue = dataBindingChild.getFormattedValue(dataRow); String strValue = oValue == null ? "" : oValue.toString(); cell.setCellValue(strValue); } } } }
From source file:com.swordlord.gozer.components.csv.GCsvList.java
License:Open Source License
private void createTableColumn(Sheet sheet) { LinkedList<ObjectBase> children = _obList.getChildren(); Row row = sheet.createRow(0); int nSize = children.size(); for (int i = 0; i < nSize; i++) { ObjectBase child = children.get(i); Cell cell = row.createCell(i);//from ww w . j av a 2 s.c o m cell.setCellValue(child.getCaption()); } }
From source file:com.tecnosur.util.Excel.java
public void ExportarMatriculados(CControlmatricula datos, String aula) { try { // Defino el Libro de Excel HSSFWorkbook wb = new HSSFWorkbook(); // Creo la Hoja en Excel Sheet sheet = wb.createSheet("matriculados"); // quito las lineas del libro para darle un mejor acabado sheet.setDisplayGridlines(false); sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 6)); // creo una nueva fila Row trow = sheet.createRow((short) 1); createTituloCell(wb, trow, 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "ALUMNOS MATRICULADOS"); Row trow2 = sheet.createRow((short) 3); createTituloCell(wb, trow2, 0, CellStyle.ALIGN_LEFT, CellStyle.VERTICAL_CENTER, "AULA: " + aula); // Creo la cabecera de mi listado en Excel Row row = sheet.createRow((short) 5); // Creo las celdas de mi fila, se puede poner un diseo a la celda_codigo createCell(wb, row, 0, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "CDIGO", true, true); createCell(wb, row, 1, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "ALUMNO", true, true); createCell(wb, row, 2, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "TIPO PAGO", true, true); createCell(wb, row, 3, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "CRONO. PAGO", true, true); createCell(wb, row, 4, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "N CUOT.", true, true); createCell(wb, row, 5, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "MON. MATR.", true, true); createCell(wb, row, 6, CellStyle.ALIGN_CENTER, CellStyle.VERTICAL_CENTER, "MON. CUOT.", true, true); // Definimos el tamao de las celdas, podemos definir un tamaa especifico o hacer que //la celda_codigo se acomode segn su tamao Sheet ssheet = wb.getSheetAt(0); ssheet.setColumnWidth(0, 60 * 40); ssheet.setColumnWidth(1, 255 * 40); ssheet.setColumnWidth(2, 90 * 40); ssheet.autoSizeColumn(3);/*w ww . j a v a2s .c o m*/ ssheet.autoSizeColumn(4); ssheet.autoSizeColumn(5); ssheet.autoSizeColumn(6); HSSFFont cellFont = wb.createFont(); cellFont.setFontHeightInPoints((short) 8); cellFont.setFontName(HSSFFont.FONT_ARIAL); CellStyle cellStyle = wb.createCellStyle(); cellStyle.setFont(cellFont); cellStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN); cellStyle.setLeftBorderColor((short) 8); cellStyle.setBorderRight(HSSFCellStyle.BORDER_THIN); cellStyle.setRightBorderColor((short) 8); cellStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN); cellStyle.setBottomBorderColor((short) 8); for (int i = 0; i < datos.size(); i++) { row = sheet.createRow((short) i + 6); Cell celda_codigo = row.createCell(0); celda_codigo.setCellStyle(cellStyle); celda_codigo.setCellValue(datos.get(i).getIdalumno()); Cell celda_alumno = row.createCell(1); celda_alumno.setCellStyle(cellStyle); celda_alumno.setCellValue(datos.get(i).getNom_completo()); Cell celda_tipopago = row.createCell(2); celda_tipopago.setCellStyle(cellStyle); celda_tipopago.setCellValue(datos.get(i).getTipopagante()); Cell celda_crono = row.createCell(3); celda_crono.setCellStyle(cellStyle); celda_crono.setCellValue(datos.get(i).getDesc_cronopagtable()); Cell celda_ncuota = row.createCell(4); celda_ncuota.setCellStyle(cellStyle); celda_ncuota.setCellValue(datos.get(i).getNum_cuota()); Cell celda_matricula = row.createCell(5); celda_matricula.setCellStyle(cellStyle); celda_matricula.setCellValue(datos.get(i).getMonmatricula()); Cell celda_moncuota = row.createCell(6); celda_moncuota.setCellStyle(cellStyle); celda_moncuota.setCellValue(datos.get(i).getMoncuota()); } String strRuta = "TYSAC_Matriculados.xls"; FileOutputStream fileOut = new FileOutputStream(strRuta); wb.write(fileOut); fileOut.close(); Runtime.getRuntime().exec("cmd /c start " + strRuta); } catch (IOException e) { System.out.println("Error de escritura"); e.printStackTrace(); } }
From source file:com.tikal.tallerWeb.servicio.reporte.cliente.AbstractSeccionXLS.java
License:Apache License
public Row getRow(Sheet sheet, int i) { Row r = sheet.getRow(i);/*from w w w . j av a 2 s . c o m*/ if (r == null) { r = sheet.createRow(i); } return r; }
From source file:com.tikal.tallerWeb.servicio.reporte.global.GeneradorReporteGlobal.java
License:Apache License
private void llenarEncabezado(Sheet sheet, int row, int col) { int cellCount = col; Cell actual;//from w ww . j av a 2 s.com Row r = sheet.createRow(row); for (String x : encabezado) { actual = r.createCell(cellCount); actual.setCellValue(x); sheet.autoSizeColumn(cellCount); cellCount = cellCount + 1; } }