List of usage examples for org.apache.poi.ss.usermodel Workbook write
void write(OutputStream stream) throws IOException;
From source file:eu.esdihumboldt.hale.io.xls.writer.XLSAlignmentMappingWriter.java
License:Open Source License
@Override protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException { super.execute(progress, reporter); Workbook workbook; // write xls file if (getContentType().getId().equals("eu.esdihumboldt.hale.io.xls.xls")) { workbook = new HSSFWorkbook(); }/* w ww .ja va2 s. c om*/ // write xlsx file else if (getContentType().getId().equals("eu.esdihumboldt.hale.io.xls.xlsx")) { workbook = new XSSFWorkbook(); } else { reporter.error(new IOMessageImpl("Content type is invalid!", null)); reporter.setSuccess(false); return reporter; } Sheet sheet = workbook.createSheet(); workbook.setSheetName(0, "Mapping table"); Row row = null; Cell cell = null; // create cell style of the header CellStyle headerStyle = XLSCellStyles.getHeaderStyle(workbook); // create cell style CellStyle cellStyle = XLSCellStyles.getNormalStyle(workbook, false); // create highlight style for type cells CellStyle highlightStyle = XLSCellStyles.getHighlightedStyle(workbook, false); // create disabled style CellStyle disabledStyle = XLSCellStyles.getNormalStyle(workbook, true); // create disabled highlight style CellStyle disabledTypeStyle = XLSCellStyles.getHighlightedStyle(workbook, true); List<Map<CellType, CellInformation>> mapping = getMappingList(); // determine if cells are organized by type cell boolean byTypeCell = isByTypeCell(); int rownum = 0; // write header row = sheet.createRow(rownum++); for (int i = 0; i < getMappingHeader().size(); i++) { cell = row.createCell(i); cell.setCellValue(getMappingHeader().get(i)); cell.setCellStyle(headerStyle); } // write all mappings for (Map<CellType, CellInformation> entry : mapping) { boolean disabled = false; if (getParameter(TRANSFORMATION_AND_DISABLED_FOR).as(Boolean.class)) { List<String> transformationDisabled = entry.get(CellType.TRANSFORMATION_AND_DISABLED).getText(); disabled = !transformationDisabled.isEmpty() && !transformationDisabled.contains(TransformationMode.active.displayName()); } // create a row row = sheet.createRow(rownum); CellStyle rowStyle = cellStyle; String targetProp = getCellValue(entry, CellType.TARGET_PROPERTIES); boolean isTypeCell = targetProp == null || targetProp.isEmpty(); if (isTypeCell && byTypeCell) { // organized by type cells and this is a type cell if (disabled) { // disabled type cell rowStyle = disabledTypeStyle; } else { // normal type cell rowStyle = highlightStyle; } } else if (disabled) { // disabled property cell rowStyle = disabledStyle; } List<CellType> celltypes = getCellTypes(); for (int i = 0; i < celltypes.size(); i++) { cell = row.createCell(i); cell.setCellValue(getCellValue(entry, celltypes.get(i))); cell.setCellStyle(rowStyle); } rownum++; } // could be integrated in configuration page // int maxColWidth = calculateWidth(getParameter(MAX_COLUMN_WIDTH).as(Integer.class)); int maxColWidth = calculateWidth(maxWidth); // autosize all columns for (int i = 0; i < getMappingHeader().size(); i++) { sheet.autoSizeColumn(i); if (sheet.getColumnWidth(i) > maxColWidth) sheet.setColumnWidth(i, maxColWidth); } // write file FileOutputStream out = new FileOutputStream(getTarget().getLocation().getPath()); workbook.write(out); out.close(); reporter.setSuccess(true); return reporter; }
From source file:eu.esdihumboldt.hale.io.xls.writer.XLSLookupTableWriter.java
License:Open Source License
/** * @see eu.esdihumboldt.hale.common.core.io.impl.AbstractIOProvider#execute(eu.esdihumboldt.hale.common.core.io.ProgressIndicator, * eu.esdihumboldt.hale.common.core.io.report.IOReporter) *//* www . j a v a 2 s .co m*/ @Override protected IOReport execute(ProgressIndicator progress, IOReporter reporter) throws IOProviderConfigurationException, IOException { Workbook workbook; // write xls file if (getContentType().getId().equals("eu.esdihumboldt.hale.io.xls.xls")) { workbook = new HSSFWorkbook(); } // write xlsx file else if (getContentType().getId().equals("eu.esdihumboldt.hale.io.xls.xlsx")) { workbook = new XSSFWorkbook(); } else { reporter.error(new IOMessageImpl("Content type is invalid!", null)); reporter.setSuccess(false); return reporter; } Sheet sheet = workbook.createSheet(); workbook.setSheetName(0, "Lookup table"); Row row = null; Cell cell = null; DataFormat df = workbook.createDataFormat(); // create cell style of the header CellStyle headerStyle = workbook.createCellStyle(); Font headerFont = workbook.createFont(); // use bold font headerFont.setBoldweight(Font.BOLDWEIGHT_BOLD); headerStyle.setFont(headerFont); // set a medium border headerStyle.setBorderBottom(CellStyle.BORDER_MEDIUM); // set cell data format to text headerStyle.setDataFormat(df.getFormat("@")); // create cell style CellStyle rowStyle = workbook.createCellStyle(); // set thin border around the cell rowStyle.setBorderBottom(CellStyle.BORDER_THIN); rowStyle.setBorderLeft(CellStyle.BORDER_THIN); rowStyle.setBorderRight(CellStyle.BORDER_THIN); // set cell data format to text rowStyle.setDataFormat(df.getFormat("@")); // display multiple lines rowStyle.setWrapText(true); Map<Value, Value> table = getLookupTable().getTable().asMap(); int rownum = 0; // write header row = sheet.createRow(rownum++); cell = row.createCell(0); cell.setCellValue(getParameter(LookupTableExportConstants.PARAM_SOURCE_COLUMN).as(String.class)); cell.setCellStyle(headerStyle); cell = row.createCell(1); cell.setCellValue(getParameter(LookupTableExportConstants.PARAM_TARGET_COLUMN).as(String.class)); cell.setCellStyle(headerStyle); for (Value key : table.keySet()) { // create a row row = sheet.createRow(rownum); cell = row.createCell(0); cell.setCellValue(key.as(String.class)); cell.setCellStyle(rowStyle); Value entry = table.get(key); cell = row.createCell(1); cell.setCellValue(entry.as(String.class)); cell.setCellStyle(rowStyle); rownum++; } // write file FileOutputStream out = new FileOutputStream(getTarget().getLocation().getPath()); workbook.write(out); out.close(); reporter.setSuccess(true); return reporter; }
From source file:eu.impact_project.resultsrepository.report.Report.java
License:Apache License
private InputStream toStream(Sheet sheet) throws IOException { Workbook excelWorkbook = sheet.getWorkbook(); ByteArrayOutputStream os = new ByteArrayOutputStream(); excelWorkbook.write(os); InputStream is = new ByteArrayInputStream(os.toByteArray()); os.close();/*from w ww . j a v a2 s .c om*/ return is; }
From source file:Excel.Exportar.java
public String exportarExcel() { String respuesta = "No se pudo exportar"; Workbook libro = new HSSFWorkbook(); Sheet hoja = libro.createSheet("Resultados"); String file = "Resultado.xls"; try {//from www . j a va 2s . c om for (int i = -1; i < 10; i++) { Row fila = hoja.createRow(i + 1); for (int j = 0; j < 2; j++) { Cell celda = fila.createCell(j); if (i == -1) { celda.setCellValue(encabezados[j]); } else { if (j == 0) { celda.setCellValue(cromosomas[i]); } else { celda.setCellValue(cromosomasMutados[i]); } } libro.write(new FileOutputStream(file)); } } respuesta = "Exportacion exitosa"; } catch (Exception e) { System.err.print(e); } return respuesta; }
From source file:Export.ExporOnlyViagemExcel.java
public void criarDoc(String user, Date dataInicio, Date dataFim) { try {//w w w.ja va2 s . co m SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh.mm.ss"); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Seguro Viagem/"); ff.mkdirs(); String Ddata = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Viagem " + Ddata + ".xls"); String reString = "../Documentos/" + user + "/Seguro Viagem/" + "Export Mapa Viagem " + Ddata + ".xls"; Workbook wb = new HSSFWorkbook(); dataTableDados(wb, dataInicio, dataFim); try (FileOutputStream out = new FileOutputStream(ff)) { wb.write(out); } catch (IOException ex) { Logger.getLogger(GenericExcel.class.getName()).log(Level.SEVERE, null, ex); } RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (ParseException ex) { Logger.getLogger(ExporOnlyViagemExcel.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.ExportMapaProducaoExcel__.java
public String criarDoc(String user, Date incio, Date fim) { try {//from w w w . j a va 2s .c om Workbook wb = new HSSFWorkbook(); Font fTitulo = wb.createFont(); fTitulo.setBoldweight(Font.BOLDWEIGHT_BOLD); fTitulo.setFontHeightInPoints((short) 22); Font fTituloP = wb.createFont(); fTituloP.setBoldweight(Font.BOLDWEIGHT_BOLD); fTituloP.setFontHeightInPoints((short) 13); Font fTituloTabela = wb.createFont(); fTituloTabela.setBoldweight(Font.BOLDWEIGHT_BOLD); fTituloTabela.setFontHeightInPoints((short) 12.5); Font fCorpoTabela = wb.createFont(); fCorpoTabela.setBoldweight(Font.BOLDWEIGHT_NORMAL); fCorpoTabela.setFontHeightInPoints((short) 11.5); Font fRodapeTabela = wb.createFont(); fRodapeTabela.setBoldweight(Font.BOLDWEIGHT_BOLD); fRodapeTabela.setFontHeightInPoints((short) 11.5); Font fNormal = wb.createFont(); fNormal.setBoldweight(Font.BOLDWEIGHT_BOLD); fNormal.setFontHeightInPoints((short) 11); CellStyle csTitulo = wb.createCellStyle(); csTitulo.setFont(fTitulo); csTitulo.setAlignment((short) 1); csTitulo.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); csTitulo.setWrapText(true); csTitulo.setBorderBottom((short) 0); csTitulo.setBorderTop((short) 0); csTitulo.setBorderRight((short) 0); csTitulo.setBorderLeft((short) 0); csTitulo.setWrapText(true); CellStyle csTituloP = wb.createCellStyle(); csTituloP.setFont(fTituloP); csTituloP.setAlignment((short) 1); csTituloP.setVerticalAlignment((short) 1); csTituloP.setWrapText(true); csTituloP.setBorderBottom((short) 0); csTituloP.setBorderTop((short) 0); csTituloP.setBorderRight((short) 0); csTituloP.setBorderLeft((short) 0); csTituloP.setWrapText(true); CellStyle csTituloT = wb.createCellStyle(); csTituloT.setFont(fTituloP); csTituloT.setAlignment((short) 1); csTituloT.setVerticalAlignment((short) 1); csTituloT.setWrapText(true); csTituloT.setBorderBottom((short) 0); csTituloT.setBorderTop((short) 0); csTituloT.setBorderRight((short) 0); csTituloT.setBorderLeft((short) 0); csTituloT.setWrapText(true); CellStyle csTituloTabela = wb.createCellStyle(); csTituloTabela.setFont(fTituloTabela); csTituloTabela.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabela.setVerticalAlignment((short) 2); csTituloTabela.setBorderBottom((short) 2); csTituloTabela.setBorderTop((short) 2); csTituloTabela.setBorderRight((short) 2); csTituloTabela.setBorderLeft((short) 2); csTituloTabela.setWrapText(true); CellStyle csCorpoTabela = wb.createCellStyle(); csCorpoTabela.setFont(fCorpoTabela); csCorpoTabela.setAlignment((short) 2); csCorpoTabela.setVerticalAlignment((short) 1); csCorpoTabela.setBorderBottom((short) 1); csCorpoTabela.setBorderTop((short) 1); csCorpoTabela.setBorderRight((short) 1); csCorpoTabela.setBorderLeft((short) 1); csCorpoTabela.setWrapText(true); CellStyle csCorpoTabelaR = wb.createCellStyle(); csCorpoTabelaR.setFont(fCorpoTabela); csCorpoTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csCorpoTabelaR.setVerticalAlignment((short) 1); csCorpoTabelaR.setBorderBottom((short) 1); csCorpoTabelaR.setBorderTop((short) 1); csCorpoTabelaR.setBorderRight((short) 1); csCorpoTabelaR.setBorderLeft((short) 1); csCorpoTabelaR.setWrapText(true); CellStyle csCorpoTabelaL = wb.createCellStyle(); csCorpoTabelaL.setFont(fCorpoTabela); csCorpoTabelaL.setAlignment(CellStyle.ALIGN_LEFT); csCorpoTabelaL.setVerticalAlignment((short) 1); csCorpoTabelaL.setBorderBottom((short) 1); csCorpoTabelaL.setBorderTop((short) 1); csCorpoTabelaL.setBorderRight((short) 1); csCorpoTabelaL.setBorderLeft((short) 1); csCorpoTabelaL.setWrapText(true); CellStyle csRodapeTabela = wb.createCellStyle(); csRodapeTabela.setFont(fRodapeTabela); csRodapeTabela.setAlignment((short) 1); csRodapeTabela.setVerticalAlignment((short) 2); csRodapeTabela.setBorderBottom((short) 2); csRodapeTabela.setBorderTop((short) 2); csRodapeTabela.setBorderRight((short) 2); csRodapeTabela.setBorderLeft((short) 2); csRodapeTabela.setWrapText(true); CellStyle csRodapeTabelaR = wb.createCellStyle(); csRodapeTabelaR.setFont(fRodapeTabela); csRodapeTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csRodapeTabelaR.setVerticalAlignment((short) 2); csRodapeTabelaR.setBorderBottom((short) 2); csRodapeTabelaR.setBorderTop((short) 2); csRodapeTabelaR.setBorderRight((short) 2); csRodapeTabelaR.setBorderLeft((short) 2); csRodapeTabelaR.setWrapText(true); CellStyle csNomal = wb.createCellStyle(); csNomal.setFont(fCorpoTabela); csNomal.setAlignment((short) 1); csNomal.setVerticalAlignment((short) 1); csNomal.setBorderBottom((short) 0); csNomal.setBorderTop((short) 0); csNomal.setBorderRight((short) 0); csNomal.setBorderLeft((short) 0); csNomal.setWrapText(true); SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); SimpleDateFormat sdfPt = new SimpleDateFormat("dd-MM-yyyy"); File ff = new File(getDiretorio() + "/" + user + "/Relatorio/"); ff.mkdirs(); String stringData = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa ProducaoExel " + stringData + ".xls"); String reString = "../Documentos/" + user + "/Relatorio/" + "Export Mapa ProducaoExel " + stringData + ".xls"; Sheet s = wb.createSheet("Mapa de produo de ".toUpperCase() + ((incio != null) ? sdfPt.format(incio) + " " : " dos Ultimos anos te hoje".toUpperCase()) + ((fim == null) ? "" : sdfPt.format(fim))); int linha = 0; // int pictureIdx; // try (InputStream inputStream = new FileInputStream("logo1.png")) { // byte[] bytes = IOUtils.toByteArray(inputStream); // pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG); // } // CreationHelper helper = wb.getCreationHelper(); // Drawing drawing = s.createDrawingPatriarch(); // ClientAnchor anchor = helper.createClientAnchor(); // anchor.setCol1(0); // anchor.setCol2(3); // anchor.setRow1(0); // Picture pict = drawing.createPicture(anchor, pictureIdx); // pict.resize(); Row r = s.createRow(linha); Cell c = r.createCell(2); CreateCell(c, r, s, csTitulo, linha, linha + 3, ConfigDoc.Empresa.NOME, 1, 22); linha += 4; r = s.createRow(linha); CreateCell(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.ENDERECO, 1, 22); linha++; r = s.createRow(linha); CreateCell(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.CAIXAPOSTAL, 1, 22); linha++; r = s.createRow(linha); CreateCell(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, 1, 22); linha++; r = s.createRow(linha); CreateCell(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.SOCIEDADE, 1, 22); ResultSet rs = ud.relatorioSeguroForImpresao(incio, fim); Consumer<HashMap<String, Object>> act = (map) -> { list = new ArrayList<>(); putNewDado(map, incio, fim); }; Call.forEchaResultSet(act, rs); for (Map.Entry<String, ArrayList<Producao>> al : hasList.entrySet()) { linha += 4; r = s.createRow(linha); CreateCell(c, r, s, csTituloT, linha, linha, al.getKey(), 1, 22); linha++; linha++; r = s.createRow(linha); CreateCell(c, r, s, csTituloTabela, linha, linha, "Nr. Factura", 1, 2); CreateCell(c, r, s, csTituloTabela, linha, linha, "Nome do Segurado", 3, 7); CreateCell(c, r, s, csTituloTabela, linha, linha, "Premio", 8, 10); CreateCell(c, r, s, csTituloTabela, linha, linha, "Imposto 6%", 11, 13); CreateCell(c, r, s, csTituloTabela, linha, linha, "Imposto 5%", 14, 16); CreateCell(c, r, s, csTituloTabela, linha, linha, "FGA 2.6%", 17, 19); CreateCell(c, r, s, csTituloTabela, linha, linha, "TOTAL", 20, 22); for (Producao pro : al.getValue()) { linha++; r = s.createRow(linha); if (!pro.DATA.equals("SOMATORIO")) { CreateCell(c, r, s, csCorpoTabela, linha, linha, pro.NUMAPOLICE, 1, 2); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, pro.CLIENTESEGURO, 3, 7); CreateCell(c, r, s, csCorpoTabelaR, linha, linha, pro.PREMIO + " " + pro.MOEDA, 8, 10); CreateCell(c, r, s, csCorpoTabelaR, linha, linha, pro.IMPOSTOCONSUMO + " " + pro.MOEDA, 11, 13); CreateCell(c, r, s, csCorpoTabelaR, linha, linha, pro.IMPOSTOSELO + " " + pro.MOEDA, 14, 16); CreateCell(c, r, s, csCorpoTabelaR, linha, linha, pro.FGA + " " + pro.MOEDA, 17, 19); CreateCell(c, r, s, csCorpoTabelaR, linha, linha, pro.VALORTOTAL + " " + pro.MOEDA, 20, 22); } else { CreateCell(c, r, s, csRodapeTabela, linha, linha, "Total " + al.getKey(), 1, 7); CreateCell(c, r, s, csRodapeTabelaR, linha, linha, pro.PREMIO + " " + pro.MOEDA, 8, 10); CreateCell(c, r, s, csRodapeTabelaR, linha, linha, pro.IMPOSTOCONSUMO + " " + pro.MOEDA, 11, 13); CreateCell(c, r, s, csRodapeTabelaR, linha, linha, pro.IMPOSTOSELO + " " + pro.MOEDA, 14, 16); CreateCell(c, r, s, csRodapeTabelaR, linha, linha, pro.FGA + " " + pro.MOEDA, 17, 19); CreateCell(c, r, s, csRodapeTabelaR, linha, linha, pro.VALORTOTAL + " " + pro.MOEDA, 20, 22); } } } try (FileOutputStream out = new FileOutputStream(ff)) { wb.write(out); } return reString; } catch (IOException ex) { Logger.getLogger(ExportMapaProducaoExcel__.class.getName()).log(Level.SEVERE, null, ex); return null; } }
From source file:Export.ExportViagemSemanaExcel.java
public static void criarDoc(Date dataInicio, Date dateFim, String user, String nomeFuncinario) { Workbook wb = new HSSFWorkbook(); Font fTitulo = wb.createFont(); fTitulo.setBoldweight(Font.BOLDWEIGHT_BOLD); fTitulo.setFontHeightInPoints((short) 14); Font fTituloP = wb.createFont(); fTituloP.setBoldweight(Font.BOLDWEIGHT_BOLD); fTituloP.setFontHeightInPoints((short) 12); // fTituloP.setStrikeout(true); fTituloP.setUnderline(Font.U_SINGLE); Font fTituloTabela = wb.createFont(); fTituloTabela.setBoldweight(Font.BOLDWEIGHT_BOLD); fTituloTabela.setFontHeightInPoints((short) 8); Font fCorpoTabela = wb.createFont(); fCorpoTabela.setBoldweight(Font.BOLDWEIGHT_NORMAL); fCorpoTabela.setFontHeightInPoints((short) 8.5); Font fRodapeTabela = wb.createFont(); fRodapeTabela.setBoldweight(Font.BOLDWEIGHT_BOLD); fRodapeTabela.setFontHeightInPoints((short) 8.5); Font fNormal = wb.createFont(); fNormal.setBoldweight(Font.BOLDWEIGHT_BOLD); fNormal.setFontHeightInPoints((short) 8.5); CellStyle csTitulo = wb.createCellStyle(); csTitulo.setFont(fTitulo);/*from w ww . j a v a 2 s. co m*/ csTitulo.setAlignment((short) 1); csTitulo.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); csTitulo.setBorderBottom((short) 0); csTitulo.setBorderTop((short) 0); csTitulo.setBorderRight((short) 0); csTitulo.setBorderLeft((short) 0); csTitulo.setWrapText(true); CellStyle csTituloP = wb.createCellStyle(); csTituloP.setFont(fTituloP); csTituloP.setAlignment((short) 1); csTituloP.setVerticalAlignment((short) 1); csTituloP.setBorderBottom((short) 0); csTituloP.setBorderTop((short) 0); csTituloP.setBorderRight((short) 0); csTituloP.setBorderLeft((short) 0); csTituloP.setWrapText(true); CellStyle csTituloT = wb.createCellStyle(); csTituloT.setFont(fTituloP); csTituloT.setAlignment((short) 1); csTituloT.setVerticalAlignment((short) 1); csTituloT.setBorderBottom((short) 0); csTituloT.setBorderTop((short) 0); csTituloT.setBorderRight((short) 0); csTituloT.setBorderLeft((short) 0); csTituloT.setWrapText(true); CellStyle csTituloTabela = wb.createCellStyle(); csTituloTabela.setFont(fTituloTabela); csTituloTabela.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabela.setVerticalAlignment((short) 2); csTituloTabela.setBorderBottom((short) 2); csTituloTabela.setBorderTop((short) 2); csTituloTabela.setBorderRight((short) 2); csTituloTabela.setBorderLeft((short) 2); csTituloTabela.setWrapText(true); CellStyle csTituloTabelaNBorder = wb.createCellStyle(); csTituloTabelaNBorder.setFont(fTituloTabela); csTituloTabelaNBorder.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabelaNBorder.setVerticalAlignment((short) 2); csTituloTabelaNBorder.setBorderBottom((short) 2); csTituloTabelaNBorder.setBorderTop((short) 2); csTituloTabelaNBorder.setBorderRight((short) 2); csTituloTabelaNBorder.setBorderLeft((short) 2); csTituloTabelaNBorder.setWrapText(true); CellStyle csCorpoTabela = wb.createCellStyle(); csCorpoTabela.setFont(fCorpoTabela); csCorpoTabela.setAlignment((short) 2); csCorpoTabela.setVerticalAlignment((short) 1); csCorpoTabela.setBorderBottom((short) 1); csCorpoTabela.setBorderTop((short) 1); csCorpoTabela.setBorderRight((short) 1); csCorpoTabela.setBorderLeft((short) 1); csCorpoTabela.setWrapText(true); CellStyle csCorpoTabelaR = wb.createCellStyle(); csCorpoTabelaR.setFont(fCorpoTabela); csCorpoTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csCorpoTabelaR.setVerticalAlignment((short) 1); csCorpoTabelaR.setBorderBottom((short) 1); csCorpoTabelaR.setBorderTop((short) 1); csCorpoTabelaR.setBorderRight((short) 1); csCorpoTabelaR.setBorderLeft((short) 1); csCorpoTabelaR.setWrapText(true); CellStyle csCorpoTabelaL = wb.createCellStyle(); csCorpoTabelaL.setFont(fCorpoTabela); csCorpoTabelaL.setAlignment(CellStyle.ALIGN_LEFT); csCorpoTabelaL.setVerticalAlignment((short) 1); csCorpoTabelaL.setBorderBottom((short) 1); csCorpoTabelaL.setBorderTop((short) 1); csCorpoTabelaL.setBorderRight((short) 1); csCorpoTabelaL.setBorderLeft((short) 1); csCorpoTabelaL.setWrapText(true); CellStyle csRodapeTabela = wb.createCellStyle(); csRodapeTabela.setFont(fRodapeTabela); csRodapeTabela.setAlignment((short) 1); csRodapeTabela.setVerticalAlignment((short) 2); csRodapeTabela.setBorderBottom((short) 2); csRodapeTabela.setBorderTop((short) 2); csRodapeTabela.setBorderRight((short) 2); csRodapeTabela.setBorderLeft((short) 2); csRodapeTabela.setWrapText(true); CellStyle csRodapeTabelaR = wb.createCellStyle(); csRodapeTabelaR.setFont(fRodapeTabela); csRodapeTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csRodapeTabelaR.setVerticalAlignment((short) 2); csRodapeTabelaR.setBorderBottom((short) 2); csRodapeTabelaR.setBorderTop((short) 2); csRodapeTabelaR.setBorderRight((short) 2); csRodapeTabelaR.setBorderLeft((short) 2); csRodapeTabelaR.setWrapText(true); CellStyle csNomal = wb.createCellStyle(); csNomal.setFont(fCorpoTabela); csNomal.setAlignment((short) 1); csNomal.setVerticalAlignment((short) 1); csNomal.setBorderBottom((short) 0); csNomal.setBorderTop((short) 0); csNomal.setBorderRight((short) 0); csNomal.setBorderLeft((short) 0); csNomal.setWrapText(true); OutputStream outputStraem; try { SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy hh.mm.ss"); SimpleDateFormat sdfTitile = new SimpleDateFormat("dd-MM-yyyy"); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Seguro Viagem/"); ff.mkdirs(); String Ddata = sdf.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Export Mapa Viagem Semanal " + Ddata + ".xls"); String reString = "../Documentos/" + user + "/Seguro Viagem/" + "Export Mapa Viagem Semanal " + Ddata + ".xls"; outputStraem = new FileOutputStream(ff); int linha = 0; Sheet s = wb.createSheet("RELATORIO SEMANAL"); Row r = s.createRow(linha); Cell c = r.createCell(2); createCellM(c, r, s, csTitulo, linha, linha + 3, ConfigDoc.Empresa.NOME, 1, 22); linha += 4; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.ENDERECO, 1, 22); linha++; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.CAIXAPOSTAL, 1, 22); linha++; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, 1, 22); linha++; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.SOCIEDADE, 1, 22); linha += 3; r = s.createRow(linha); createCellM(c, r, s, csTituloTabelaNBorder, linha, linha + 1, "RELATORIO SEMANAL NO. " + "" + "\n" + ((dataInicio != null) ? sdfTitile.format(dataInicio) + " - " : "") + ((dateFim != null) ? sdfTitile.format(dateFim) : ""), 1, 10); linha += 3; r = s.createRow(linha); c = r.createCell(2); createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(0), 1, 4); //1 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(1), 2, 6); //2 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(2), 3, 6); //1 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(3), 4, 6); //1 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(4), 5, 6); //2 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(5), 6, 20); //3 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(6), 7, 4); //1 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(7), 8, 4); //1 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(8), 9, 8); //2 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(9), 10, 8); //1 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(10), 11, 6); //2 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(11), 12, 6); //2 createCell(c, r, s, csTituloTabela, linha, linha + 1, titileTable(12), 13, 6); //2 dataViagem(dataInicio, dateFim); float premiototal = 0; linha++; for (HashMap<String, Object> data : hasList) { linha++; r = s.createRow(linha); c = r.createCell(2); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(DATA)), 1, 4); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(NUMEROAPOLICE)), 2, 6); createCell(c, r, s, csCorpoTabelaL, linha, linha, ConfigDoc.toFormat(toString(data.get(INICIO)), "dd-MM-yyyy", "yyyy-MM-dd"), 3, 6); createCell(c, r, s, csCorpoTabelaL, linha, linha, ConfigDoc.toFormat(toString(data.get(FIM)), "dd-MM-yyyy", "yyyy-MM-dd"), 4, 6); premiototal += toFloat(data.get(PREMIO)); createCell(c, r, s, csCorpoTabelaR, linha, linha, ConfigDoc.toMoeda(toFloat(data.get(PREMIO)), ""), 5, 6); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(CLIENTE)), 6, 20); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(DATANASCIMENTO)), 7, 4); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(TELEFONE)), 8, 4); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(ENDERECO)), 9, 8); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(LOCALNASCIMENTO)), 10, 8); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(PAISDESTINO)), 11, 6); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(CIDADEDESTINO)), 12, 6); createCell(c, r, s, csCorpoTabelaL, linha, linha, toString(data.get(ZONADESTINO)), 13, 6); } linha++; r = s.createRow(linha); c = r.createCell(2); createCellM(c, r, s, csRodapeTabela, linha, linha, "AL AMOUNT..........................................", 1, 5); createCellM(c, r, s, csRodapeTabelaR, linha, linha, ConfigDoc.toMoeda(premiototal, ""), 6, 7); createCellM(c, r, s, csRodapeTabela, linha, linha, " ", 8, 13); try (FileOutputStream out = new FileOutputStream(ff)) { wb.write(out); } catch (IOException ex) { Logger.getLogger(GenericExcel.class.getName()).log(Level.SEVERE, null, ex); } RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (FileNotFoundException ex) { Logger.getLogger(ExportViagemSemanaExcel.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Export.GenericExcel.java
/** * * @param user/*from w w w . j a v a2s . c o m*/ * @param nomeDoc * @param titleDoc * @param rs * @param paramFilter * @return */ public static String createDoc(String user, String nomeDoc, String titleDoc, DataTableControl rs, int paramFilter) { OutputStream outputStraem = null; try { i = 0; SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + nomeDoc + " " + Ddata + ".xls"); outputStraem = new FileOutputStream(ff); reString = "../Documentos/" + user + "/Relatorio/" + nomeDoc + " " + Ddata + ".xls"; getMap(rs, paramFilter); float[] colun = createPerncetage(list, paramFilter); Workbook wb = new HSSFWorkbook(); Font fTitulo = wb.createFont(); fTitulo.setBoldweight(Font.BOLDWEIGHT_BOLD); fTitulo.setFontHeightInPoints((short) 14); Font fTituloP = wb.createFont(); fTituloP.setBoldweight(Font.BOLDWEIGHT_BOLD); fTituloP.setFontHeightInPoints((short) 12); fTituloP.setUnderline(Font.U_SINGLE); Font fTituloTabela = wb.createFont(); fTituloTabela.setBoldweight(Font.BOLDWEIGHT_BOLD); fTituloTabela.setFontHeightInPoints((short) 8); Font fCorpoTabela = wb.createFont(); fCorpoTabela.setBoldweight(Font.BOLDWEIGHT_NORMAL); fCorpoTabela.setFontHeightInPoints((short) 8.5); Font fRodapeTabela = wb.createFont(); fRodapeTabela.setBoldweight(Font.BOLDWEIGHT_BOLD); fRodapeTabela.setFontHeightInPoints((short) 8.5); Font fNormal = wb.createFont(); fNormal.setBoldweight(Font.BOLDWEIGHT_BOLD); fNormal.setFontHeightInPoints((short) 8.5); CellStyle csTitulo = wb.createCellStyle(); csTitulo.setFont(fTitulo); csTitulo.setAlignment((short) 1); csTitulo.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); csTitulo.setBorderBottom((short) 0); csTitulo.setBorderTop((short) 0); csTitulo.setBorderRight((short) 0); csTitulo.setBorderLeft((short) 0); csTitulo.setWrapText(true); CellStyle csTituloP = wb.createCellStyle(); csTituloP.setFont(fTituloP); csTituloP.setAlignment((short) 1); csTituloP.setVerticalAlignment((short) 1); csTituloP.setBorderBottom((short) 0); csTituloP.setBorderTop((short) 0); csTituloP.setBorderRight((short) 0); csTituloP.setBorderLeft((short) 0); csTituloP.setWrapText(true); CellStyle csTituloT = wb.createCellStyle(); csTituloT.setFont(fTituloP); csTituloT.setAlignment((short) 1); csTituloT.setVerticalAlignment((short) 1); csTituloT.setBorderBottom((short) 0); csTituloT.setBorderTop((short) 0); csTituloT.setBorderRight((short) 0); csTituloT.setBorderLeft((short) 0); csTituloT.setWrapText(true); CellStyle csTituloTabela = wb.createCellStyle(); csTituloTabela.setFont(fTituloTabela); csTituloTabela.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabela.setVerticalAlignment((short) 2); csTituloTabela.setBorderBottom((short) 2); csTituloTabela.setBorderTop((short) 2); csTituloTabela.setBorderRight((short) 2); csTituloTabela.setBorderLeft((short) 2); csTituloTabela.setWrapText(true); CellStyle csTituloTabelaNBorder = wb.createCellStyle(); csTituloTabelaNBorder.setFont(fTituloTabela); csTituloTabelaNBorder.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabelaNBorder.setVerticalAlignment((short) 2); csTituloTabelaNBorder.setBorderBottom((short) 2); csTituloTabelaNBorder.setBorderTop((short) 2); csTituloTabelaNBorder.setBorderRight((short) 2); csTituloTabelaNBorder.setBorderLeft((short) 2); csTituloTabelaNBorder.setWrapText(true); CellStyle csCorpoTabela = wb.createCellStyle(); csCorpoTabela.setFont(fCorpoTabela); csCorpoTabela.setAlignment((short) 2); csCorpoTabela.setVerticalAlignment((short) 1); csCorpoTabela.setBorderBottom((short) 1); csCorpoTabela.setBorderTop((short) 1); csCorpoTabela.setBorderRight((short) 1); csCorpoTabela.setBorderLeft((short) 1); csCorpoTabela.setWrapText(true); CellStyle csCorpoTabelaR = wb.createCellStyle(); csCorpoTabelaR.setFont(fCorpoTabela); csCorpoTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csCorpoTabelaR.setVerticalAlignment((short) 1); csCorpoTabelaR.setBorderBottom((short) 1); csCorpoTabelaR.setBorderTop((short) 1); csCorpoTabelaR.setBorderRight((short) 1); csCorpoTabelaR.setBorderLeft((short) 1); csCorpoTabelaR.setWrapText(true); CellStyle csCorpoTabelaL = wb.createCellStyle(); csCorpoTabelaL.setFont(fCorpoTabela); csCorpoTabelaL.setAlignment(CellStyle.ALIGN_LEFT); csCorpoTabelaL.setVerticalAlignment((short) 1); csCorpoTabelaL.setBorderBottom((short) 1); csCorpoTabelaL.setBorderTop((short) 1); csCorpoTabelaL.setBorderRight((short) 1); csCorpoTabelaL.setBorderLeft((short) 1); csCorpoTabelaL.setWrapText(true); CellStyle csRodapeTabelaL = wb.createCellStyle(); csRodapeTabelaL.setFont(fRodapeTabela); csRodapeTabelaL.setAlignment(CellStyle.ALIGN_CENTER); csRodapeTabelaL.setVerticalAlignment((short) 2); csRodapeTabelaL.setBorderBottom((short) 2); csRodapeTabelaL.setBorderTop((short) 2); csRodapeTabelaL.setBorderRight((short) 2); csRodapeTabelaL.setBorderLeft((short) 2); csRodapeTabelaL.setWrapText(true); CellStyle csRodapeTabela = wb.createCellStyle(); csRodapeTabela.setFont(fRodapeTabela); csRodapeTabela.setAlignment(CellStyle.ALIGN_CENTER); csRodapeTabela.setVerticalAlignment((short) 2); csRodapeTabela.setBorderBottom((short) 2); csRodapeTabela.setBorderTop((short) 2); csRodapeTabela.setBorderRight((short) 2); csRodapeTabela.setBorderLeft((short) 2); csRodapeTabela.setWrapText(true); CellStyle csRodapeTabelaR = wb.createCellStyle(); csRodapeTabelaR.setFont(fRodapeTabela); csRodapeTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csRodapeTabelaR.setVerticalAlignment((short) 2); csRodapeTabelaR.setBorderBottom((short) 2); csRodapeTabelaR.setBorderTop((short) 2); csRodapeTabelaR.setBorderRight((short) 2); csRodapeTabelaR.setBorderLeft((short) 2); csRodapeTabelaR.setWrapText(true); CellStyle csNomal = wb.createCellStyle(); csNomal.setFont(fCorpoTabela); csNomal.setAlignment((short) 1); csNomal.setVerticalAlignment((short) 1); csNomal.setBorderBottom((short) 0); csNomal.setBorderTop((short) 0); csNomal.setBorderRight((short) 0); csNomal.setBorderLeft((short) 0); csNomal.setWrapText(true); Sheet s = wb.createSheet(titleDoc); linha = 0; Row r = s.createRow(linha); Cell c = r.createCell(2); createCellM(c, r, s, csTitulo, linha, linha + 3, ConfigDoc.Empresa.NOME, 1, 22); linha += 4; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.ENDERECO, 1, 22); linha++; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.CAIXAPOSTAL, 1, 22); linha++; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, 1, 22); linha++; r = s.createRow(linha); createCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.SOCIEDADE, 1, 22); linha += 3; r = s.createRow(linha); SimpleDateFormat format = new SimpleDateFormat("dd 'de' MMMM 'de' yyyy", new Locale("pt", "BR")); createCellM(c, r, s, csTituloT, linha, linha, titleDoc.toUpperCase() + ((dF != null && dI != null) ? (" de " + format.format(dI) + " " + format.format(dF)).toUpperCase() : ""), 1, 22); linha += 2; if (paramFilter < 0) { for (Object[] emap : list) { k = 0; r = s.createRow(linha); for (int j = 0; j < emap.length; j++) { if (j != paramFilterOculta) { if (i == 0) { lista_titulo_table = emap; csCorpoTabela.setFillBackgroundColor(HSSFColor.BLUE.index); createCell(c, r, s, csTituloTabela, linha, linha, toString(emap[j]), k + 1, toInt(colun[k])); k++; } else { csCorpoTabelaL.setFillBackgroundColor( ((i % 2) == 0) ? HSSFColor.WHITE.index : HSSFColor.GREY_25_PERCENT.index); createCell(c, r, s, ((alignment.containsKey(j)) ? ((alignment.get(j) == Alignment.RIGHT) ? csCorpoTabelaR : ((alignment.get(j) == Alignment.CENTER) ? csCorpoTabela : csCorpoTabelaL)) : csCorpoTabelaL), linha, linha, toString(emap[j]), k + 1, toInt(colun[k])); k++; } } } i++; linha++; } for (Map.Entry<String, ArrayList<Object[]>> entrySet : mapTotal.entrySet()) { for (Object[] emapT : entrySet.getValue()) { k = 0; r = s.createRow(linha); for (int j = 0; j < emapT.length; j++) { if (j != paramFilterOculta) { csCorpoTabelaL.setFillBackgroundColor(HSSFColor.LIGHT_BLUE.index); createCell(c, r, s, ((alignment.containsKey(j)) ? ((alignment.get(j) == Alignment.RIGHT) ? csRodapeTabelaR : ((alignment.get(j) == Alignment.CENTER) ? csRodapeTabelaR : csRodapeTabelaL)) : csRodapeTabelaL), linha, linha, ((j == 0) ? "TOTAL" : toString(emapT[j])), k + 1, toInt(colun[k])); k++; } } } } } else { int t = 0; for (Map.Entry<String, ArrayList<Object[]>> lista : map.entrySet()) { r = s.createRow(linha); csTituloTabela.setFillBackgroundColor(HSSFColor.WHITE.index); createCellM(c, r, s, csTituloTabelaNBorder, linha, linha, toString(lista.getKey()), 1, 7); linha += 2; for (Object[] emap : lista.getValue()) { k = 0; r = s.createRow(linha); for (int j = 0; j < emap.length; j++) { if (j != paramFilterOculta) { if (i == 0) { lista_titulo_table = emap; csTituloTabela.setFillBackgroundColor(HSSFColor.BLUE.index); createCell(c, r, s, csTituloTabela, linha, linha, toString(emap[j]), k + 1, toInt(colun[k])); k++; } else { csCorpoTabelaL.setFillBackgroundColor(((i % 2) == 0) ? HSSFColor.WHITE.index : HSSFColor.GREY_25_PERCENT.index); createCell(c, r, s, ((alignment.containsKey(j)) ? ((alignment.get(j) == Alignment.RIGHT) ? csCorpoTabelaR : ((alignment.get(j) == Alignment.CENTER) ? csCorpoTabela : csCorpoTabelaL)) : csCorpoTabelaL), linha, linha, toString(emap[j]), k + 1, toInt(colun[k])); k++; } } } i++; linha++; } if (mapTotal.containsKey(lista.getKey())) { for (Object[] emapT : mapTotal.get(lista.getKey())) { k = 0; r = s.createRow(linha); for (int j = 0; j < emapT.length; j++) { if (j != paramFilterOculta) { createCell(c, r, s, ((alignment.containsKey(j)) ? ((alignment.get(j) == Alignment.RIGHT) ? csRodapeTabelaR : ((alignment.get(j) == Alignment.CENTER) ? csRodapeTabela : csRodapeTabelaL)) : csRodapeTabelaL), linha, linha, ((j == 0) ? "TOTAL" : toString(emapT[j])), k + 1, toInt(colun[k])); k++; } } } } t++; i = 0; linha += 3; if (t == map.size() && paramFilter > -1) { k = 0; r = s.createRow(linha); for (int j = 0; j < lista_titulo_table.length; j++) { if (j != paramFilterOculta) { csTituloTabela.setFillBackgroundColor(HSSFColor.BLUE.index); createCell(c, r, s, csTituloTabela, linha, linha, toString(lista_titulo_table[j]), k + 1, toInt(colun[k])); k++; } } linha++; Double[] total_total = new Double[lista_titulo_table.length]; for (Map.Entry<String, ArrayList<Object[]>> lista_for_total : map.entrySet()) { String key = lista_for_total.getKey(); for (Object[] emapT : mapTotal.get(key)) { k = 0; r = s.createRow(linha); for (int j = 0; j < emapT.length; j++) { if (j != paramFilterOculta) { if (Moeda.unFormat(toString(emapT[j]).replaceAll(" ", "") .replaceAll(",", ".").replaceAll("STD", "")) != -1) { Double v = ((total_total[j] == null) ? 0.0 : total_total[j]); total_total[j] = Moeda.unFormat(toString(emapT[j]).replaceAll(" ", "") .replaceAll(",", ".").replaceAll("STD", "")) + v; } createCell(c, r, s, ((alignment.containsKey(j)) ? ((alignment.get(j) == Alignment.RIGHT) ? csRodapeTabelaR : ((alignment.get(j) == Alignment.CENTER) ? csRodapeTabela : csRodapeTabelaL)) : csRodapeTabelaL), linha, linha, ((j == 0) ? "TOTAL " + key.toUpperCase() : toString(emapT[j])), k + 1, toInt(colun[k])); k++; } } } linha++; } k = 0; r = s.createRow(linha); for (int j = 0; j < total_total.length; j++) { if (j != paramFilterOculta) { csTituloTabela.setFillBackgroundColor(HSSFColor.BLUE.index); createCell(c, r, s, ((alignment.containsKey(j)) ? ((alignment.get(j) == Alignment.RIGHT) ? csRodapeTabelaR : ((alignment.get(j) == Alignment.CENTER) ? csRodapeTabela : csRodapeTabelaL)) : csRodapeTabelaL), linha, linha, (total_total[j] != null) ? Moeda.format_are(total_total[j]) : " ", k + 1, toInt(colun[k])); k++; } } } } } try (FileOutputStream out = new FileOutputStream(ff)) { wb.write(out); } catch (IOException ex) { Logger.getLogger(GenericExcel.class.getName()).log(Level.SEVERE, null, ex); } RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); no = false; nomeNo = ""; dI = null; dF = null; paramFilterOculta = -1; removeItem = new int[] {}; renameItem = new HashMap<>(); alignment = new HashMap<>(); valoresTotal = new String[] {}; arrValoresTotal = new int[] {}; return reString; } catch (FileNotFoundException ex) { Logger.getLogger(GenericExcel.class.getName()).log(Level.SEVERE, null, ex); return reString; } }
From source file:Export.ListaVeiculo.java
public static void criarDocExcel(List<Veiculo> ls, String user) { try {//from ww w . j a v a 2 s . c om SimpleDateFormat sdf1 = new SimpleDateFormat("dd-MM-yyyy hh'.'mm'.'ss"); File ff = new File(ConfigDoc.Fontes.getDiretorio() + "/" + user + "/Relatorio"); ff.mkdirs(); String Ddata = sdf1.format(new Date()); ff = new File(ff.getAbsoluteFile() + "/" + "Lista de Veiculos" + " " + Ddata + ".xls"); FileOutputStream outputStraem = new FileOutputStream(ff); String reString = "../Documentos/" + user + "/Relatorio/" + "Lista de Veiculos" + " " + Ddata + ".xls"; Workbook wb = new HSSFWorkbook(); org.apache.poi.ss.usermodel.Font fTitulo = wb.createFont(); fTitulo.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fTitulo.setFontHeightInPoints((short) 22); org.apache.poi.ss.usermodel.Font fTituloP = wb.createFont(); fTituloP.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fTituloP.setFontHeightInPoints((short) 15); // fTituloP.setStrikeout(true); fTituloP.setUnderline(org.apache.poi.ss.usermodel.Font.U_SINGLE); org.apache.poi.ss.usermodel.Font fTituloTabela = wb.createFont(); fTituloTabela.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fTituloTabela.setFontHeightInPoints((short) 11); org.apache.poi.ss.usermodel.Font fCorpoTabela = wb.createFont(); fCorpoTabela.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_NORMAL); fCorpoTabela.setFontHeightInPoints((short) 11.5); org.apache.poi.ss.usermodel.Font fRodapeTabela = wb.createFont(); fRodapeTabela.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fRodapeTabela.setFontHeightInPoints((short) 11.5); org.apache.poi.ss.usermodel.Font fNormal = wb.createFont(); fNormal.setBoldweight(org.apache.poi.ss.usermodel.Font.BOLDWEIGHT_BOLD); fNormal.setFontHeightInPoints((short) 11); CellStyle csTitulo = wb.createCellStyle(); csTitulo.setFont(fTitulo); csTitulo.setAlignment((short) 1); csTitulo.setVerticalAlignment(CellStyle.VERTICAL_BOTTOM); // csTitulo.setWrapText(true); csTitulo.setBorderBottom((short) 0); csTitulo.setBorderTop((short) 0); csTitulo.setBorderRight((short) 0); csTitulo.setBorderLeft((short) 0); // csTitulo.setWrapText(true); CellStyle csTituloP = wb.createCellStyle(); csTituloP.setFont(fTituloP); csTituloP.setAlignment((short) 1); csTituloP.setVerticalAlignment((short) 1); // csTituloP.setWrapText(true); csTituloP.setBorderBottom((short) 0); csTituloP.setBorderTop((short) 0); csTituloP.setBorderRight((short) 0); csTituloP.setBorderLeft((short) 0); // csTituloP.setWrapText(true); CellStyle csTituloT = wb.createCellStyle(); csTituloT.setFont(fTituloP); csTituloT.setAlignment((short) 1); csTituloT.setVerticalAlignment((short) 1); // csTituloT.setWrapText(true); csTituloT.setBorderBottom((short) 0); csTituloT.setBorderTop((short) 0); csTituloT.setBorderRight((short) 0); csTituloT.setBorderLeft((short) 0); // csTituloT.setWrapText(true); CellStyle csTituloTabela = wb.createCellStyle(); csTituloTabela.setFont(fTituloTabela); csTituloTabela.setAlignment(CellStyle.ALIGN_CENTER); csTituloTabela.setVerticalAlignment((short) 2); csTituloTabela.setBorderBottom((short) 2); csTituloTabela.setBorderTop((short) 2); csTituloTabela.setBorderRight((short) 2); csTituloTabela.setBorderLeft((short) 2); // csTituloTabela.setWrapText(true); CellStyle csCorpoTabela = wb.createCellStyle(); csCorpoTabela.setFont(fCorpoTabela); csCorpoTabela.setAlignment((short) 2); csCorpoTabela.setVerticalAlignment((short) 1); csCorpoTabela.setBorderBottom((short) 1); csCorpoTabela.setBorderTop((short) 1); csCorpoTabela.setBorderRight((short) 1); csCorpoTabela.setBorderLeft((short) 1); // csCorpoTabela.setWrapText(true); CellStyle csCorpoTabelaR = wb.createCellStyle(); csCorpoTabelaR.setFont(fCorpoTabela); csCorpoTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csCorpoTabelaR.setVerticalAlignment((short) 1); csCorpoTabelaR.setBorderBottom((short) 1); csCorpoTabelaR.setBorderTop((short) 1); csCorpoTabelaR.setBorderRight((short) 1); csCorpoTabelaR.setBorderLeft((short) 1); // csCorpoTabelaR.setWrapText(true); CellStyle csCorpoTabelaL = wb.createCellStyle(); csCorpoTabelaL.setFont(fCorpoTabela); csCorpoTabelaL.setAlignment(CellStyle.ALIGN_LEFT); csCorpoTabelaL.setVerticalAlignment((short) 1); csCorpoTabelaL.setBorderBottom((short) 1); csCorpoTabelaL.setBorderTop((short) 1); csCorpoTabelaL.setBorderRight((short) 1); csCorpoTabelaL.setBorderLeft((short) 1); // csCorpoTabelaL.setWrapText(true); CellStyle csRodapeTabela = wb.createCellStyle(); csRodapeTabela.setFont(fRodapeTabela); csRodapeTabela.setAlignment((short) 1); csRodapeTabela.setVerticalAlignment((short) 2); csRodapeTabela.setBorderBottom((short) 2); csRodapeTabela.setBorderTop((short) 2); csRodapeTabela.setBorderRight((short) 2); csRodapeTabela.setBorderLeft((short) 2); // csRodapeTabela.setWrapText(true); CellStyle csRodapeTabelaR = wb.createCellStyle(); csRodapeTabelaR.setFont(fRodapeTabela); csRodapeTabelaR.setAlignment(CellStyle.ALIGN_RIGHT); csRodapeTabelaR.setVerticalAlignment((short) 2); csRodapeTabelaR.setBorderBottom((short) 2); csRodapeTabelaR.setBorderTop((short) 2); csRodapeTabelaR.setBorderRight((short) 2); csRodapeTabelaR.setBorderLeft((short) 2); // csRodapeTabelaR.setWrapText(true); CellStyle csNomal = wb.createCellStyle(); csNomal.setFont(fCorpoTabela); csNomal.setAlignment((short) 1); csNomal.setVerticalAlignment((short) 1); csNomal.setBorderBottom((short) 0); csNomal.setBorderTop((short) 0); csNomal.setBorderRight((short) 0); csNomal.setBorderLeft((short) 0); // csNomal.setWrapText(true); Sheet s = wb.createSheet("Lista de Veiculos"); short linha = 0; Row r = s.createRow(linha); Cell c = r.createCell(2); CreateCellM(c, r, s, csTitulo, linha, linha + 3, ConfigDoc.Empresa.NOME, 1, 22); linha += 4; r = s.createRow(linha); CreateCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.ENDERECO, 1, 22); linha++; r = s.createRow(linha); CreateCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.CAIXAPOSTAL, 1, 22); linha++; r = s.createRow(linha); CreateCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.TELEFAX + " " + ConfigDoc.Empresa.EMAIL, 1, 22); linha++; r = s.createRow(linha); CreateCellM(c, r, s, csTituloP, linha, linha, ConfigDoc.Empresa.SOCIEDADE, 1, 22); linha += 3; r = s.createRow(linha); CreateCellM(c, r, s, csTituloT, linha, linha, "Lista de Veiculos".toUpperCase(), 1, 22); linha += 2; csCorpoTabela.setFillBackgroundColor(HSSFColor.BLUE.index); r = s.createRow(linha); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(0), 1, 8); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(1), 2, 18); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(2), 3, 18); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(3), 4, 18); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(4), 5, 18); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(5), 6, 10); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(6), 7, 10); CreateCell(c, r, s, csTituloTabela, linha, linha, getList(7), 8, 8); linha++; for (int i = 0; i < ls.size(); i++) { r = s.createRow(linha); csCorpoTabelaL.setFillBackgroundColor( ((i % 2) == 0) ? HSSFColor.WHITE.index : HSSFColor.GREY_25_PERCENT.index); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, ls.get(i).getNumeroMatricula(), 1, 8); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, ls.get(i).getMarca(), 2, 18); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, ls.get(i).getModelo(), 3, 18); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, ls.get(i).getNumMotor(), 4, 18); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, ls.get(i).getChassi(), 5, 18); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, (ls.get(i).getAnoFabrico() == null || ls.get(i).getAnoFabrico().equals("")) ? "" : Integer.valueOf(ls.get(i).getAnoFabrico()), 6, 10); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, (ls.get(i).getAnoCompra() == null || ls.get(i).getAnoCompra().equals("")) ? "" : Integer.valueOf(ls.get(i).getAnoCompra()), 7, 10); CreateCell(c, r, s, csCorpoTabelaL, linha, linha, Integer.valueOf(ls.get(i).getCapacidade()), 8, 8); linha++; } try (FileOutputStream out = new FileOutputStream(ff)) { wb.write(out); } catch (IOException ex) { Logger.getLogger(GenericExcel.class.getName()).log(Level.SEVERE, null, ex); } RequestContext.getCurrentInstance().execute("openAllDocument('" + reString + "')"); } catch (IOException ex) { Logger.getLogger(GenericExcel.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:facebook.insights.Inicio.java
/** * @param args the command line arguments */// w ww. j a va2 s . co m public static void main(String[] args) { // El Token solo dura 2 meses Metricas issuac = new Metricas( "CAAImAGMzn20BAF8yhGFZBNXP8LEnZCElzzSoX0Ll6uY1APzZBnAT9LVZCQ0dP1AKPxL8C1qybyyz7xfGCOLo3ew3W3IpJkZC8XNKvEsywyCCZBOaicIA1tQZCFWknQ1MdREu2BZCAoK3M0Y6yvm0whZCKgWrNHF4AuA8eSm8saoxIiUtqNFf3cq4F", "120472297979101"); Inicio obj = new Inicio(); try { // Se crea el libro Workbook libro = new XSSFWorkbook(); // Se crea una hoja dentro del libro Sheet hoja = libro.createSheet("Metricas 2014 by Flock"); // Se crea una fila dentro de la hoja Row fila = hoja.createRow(0); // Se crea una celda dentro de la fila Cell celda = fila.createCell(1); // Se crea el contenido de la celda y se mete en ella. celda.setCellValue("Insights X"); List<Row> filas = new ArrayList<>(); int recorrete = 1; for (int e = 2; e < 255; e++) { Row filad = hoja.createRow(e); filas.add(filad); } /************************************/ // Metrica // JSONObject ob = issuac.page_fan_removes(); JSONArray x = ob.getJSONArray("data"); JSONArray y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_removes", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_removes_unique(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_removes_unique", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_adds_by_paid_non_paid_unique(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_adds_by_paid_non_paid_unique", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_adds(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_adds", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_fan_adds_unique(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_fan_adds_unique", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_login_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_login_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_logout_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_logout_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_login_top_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_login_top_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_tab_views_logout_top_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_tab_views_logout_top_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_views_external_referrals_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_views_external_referrals_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_story_type_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_story_type_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_age_gender_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_age_gender_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_age_gender_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_age_gender_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_age_gender_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_age_gender_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_country_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_country_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_country_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_country_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_country_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_country_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_locale_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_locale_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_locale_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_locale_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_locale_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_locale_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_city_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_city_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_city_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_city_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_city_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_city_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_age_gender_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_age_gender_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_age_gender_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_age_gender_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_country_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_country_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_country_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_country_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_country_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_country_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_city_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_city_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_city_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_city_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_city_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_city_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_locale_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_locale_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_locale_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_locale_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_story_adds_by_locale_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_story_adds_by_locale_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_paid_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_paid_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_organic_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_organic_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_viral_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_viral_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_story_type_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_story_type_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_impressions_by_paid_non_paid_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_impressions_by_paid_non_paid_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_total_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_total_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_places_checkin_mobile_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_places_checkin_mobile_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_unique_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_unique_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_paid_days_28(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_paid_days_28", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_organic_unique_day(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_organic_unique_day", hoja, y, filas); recorrete += 3; /*****************************************************************/ // Metrica // ob = issuac.page_posts_impressions_organic_unique_week(); x = ob.getJSONArray("data"); y = (JSONArray) x.getJSONObject(0).get("values"); obj.recorre(recorrete, "page_posts_impressions_organic_unique_week", hoja, y, filas); recorrete += 3; /*****************************************************************/ FileOutputStream elFichero = new FileOutputStream("Metricas.xlsx"); libro.write(elFichero); elFichero.close(); } catch (Exception e) { System.err.println("Fallo" + e); } }