Advertisement
Guest User

GeraRelarorio

a guest
Jul 24th, 2015
426
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 26.39 KB | None | 0 0
  1. public class RelatorioExcel {
  2.  
  3.     public String caminho;
  4.  
  5.     public String geraExcell(UnimedPagamento listaPagamento, List<UnimedPagamentoLista> ListaGuiaPag, UnimedCabecalho listaCabecalho,
  6.             String nomeArquivo, List<UnimedLote> listaContatoslt, List<GlosaLote> listaGlosa) {
  7.         Date hoje = new Date();
  8.         SimpleDateFormat df;
  9.         df = new SimpleDateFormat("dd-MM-yyyy");
  10.         String dataSistema = df.format(hoje);
  11.  
  12.         try {
  13.  
  14.             FileOutputStream out = new FileOutputStream("C:\\relatorios/"+dataSistema+"/" + nomeArquivo + ".xlsx");
  15.             caminho = "C:\\relatorios/"+dataSistema+"/" + nomeArquivo + ".xls";
  16.             XSSFWorkbook wb = new XSSFWorkbook();
  17.             XSSFSheet sheet = wb.createSheet("Resumo");
  18.             XSSFSheet sheet1 = wb.createSheet("Analítico");
  19.             XSSFSheet sheet2 = wb.createSheet("Glosa");
  20.             Font negrito = wb.createFont();
  21.             Font f2 = wb.createFont();
  22.             Font f = wb.createFont();
  23.  
  24.             //Linha de titulo
  25.             XSSFRow title = sheet.createRow(0);
  26.  
  27.             for (int i = 0; i <= 2; i++) {
  28.                 title.createCell(i);
  29.             }
  30.  
  31.             //Alinhamento do estilo
  32.             XSSFCellStyle styleTitle = wb.createCellStyle();
  33.             styleTitle.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  34.             negrito.setBoldweight(Font.BOLDWEIGHT_BOLD);
  35.             styleTitle.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
  36.             styleTitle.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
  37.             styleTitle.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
  38.             styleTitle.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
  39.             //Deixa o titulo em Negrito
  40.             styleTitle.setFont(negrito);
  41.  
  42.             CellStyle cs2 = wb.createCellStyle();
  43.             CellStyle cs = wb.createCellStyle();
  44.  
  45.             //Deixa campos com o tipo moeda
  46.             XSSFCellStyle estilo = wb.createCellStyle();
  47.  
  48.             XSSFDataFormat format = wb.createDataFormat();
  49.             estilo.setDataFormat(format.getFormat("R$#,##0.00_);[Red](R$#,##0.00)"));
  50.             estilo.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  51.             estilo.setFont(negrito);
  52.             estilo.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
  53.             estilo.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
  54.             estilo.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
  55.             estilo.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
  56.  
  57.             //bordas
  58.             XSSFCellStyle estilo1 = wb.createCellStyle();
  59.             estilo1.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
  60.             estilo1.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
  61.             estilo1.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
  62.             estilo1.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
  63.  
  64.             //Fonte vermelha com formatação Moeda
  65.             f2.setColor((short) Font.COLOR_RED);
  66.             f2.setBoldweight(Font.BOLDWEIGHT_BOLD);
  67.             cs2.setDataFormat(format.getFormat("R$#,##0.00_);(R$#,##0.00)"));
  68.             cs2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  69.             cs2.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
  70.             cs2.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
  71.             cs2.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
  72.             cs2.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
  73.             cs2.setFont(f2);
  74.  
  75.             CellStyle style = wb.createCellStyle();
  76.             Font fonts = wb.createFont();
  77.             fonts.setColor(HSSFColor.GREEN.index);
  78.             fonts.setBoldweight(Font.BOLDWEIGHT_BOLD);
  79.             style.setDataFormat(format.getFormat("R$#,##0.00_);(R$#,##0.00)"));
  80.             style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  81.             style.setBorderBottom(HSSFCellStyle.BORDER_DOUBLE);
  82.             style.setBorderTop(HSSFCellStyle.BORDER_DOUBLE);
  83.             style.setBorderRight(HSSFCellStyle.BORDER_DOUBLE);
  84.             style.setBorderLeft(HSSFCellStyle.BORDER_DOUBLE);
  85.             style.setFont(fonts);
  86.             //Fonte vermelha com formatação Moeda
  87.  
  88.             //Mescla as celulas do titulo
  89.             sheet.addMergedRegion(CellRangeAddress.valueOf("$A$1:$B$1"));
  90.             XSSFCell titleCell = title.getCell(0);
  91.             titleCell.setCellStyle(styleTitle);
  92.  
  93.             titleCell.setCellValue("Resumo");
  94.  
  95.             //1º Grupo de linhas
  96.             XSSFRow cabRow = sheet.createRow(1);
  97.             for (int i = 0; i <= 2; i++) {
  98.                 cabRow.createCell(i);
  99.  
  100.             }
  101.  
  102.             XSSFCell CellA2 = cabRow.getCell(0);
  103.             CellA2.setCellValue("Nome: " + listaPagamento.getNomePrestador());
  104.             CellA2.setCellStyle(estilo);
  105.             sheet.setColumnWidth(0, 18000);
  106.             XSSFCell cellB2 = cabRow.getCell(1);
  107.             cellB2.setCellValue("Cod. Prestador: " + listaPagamento.getCodigoPrestador());
  108.             cellB2.setCellStyle(estilo);
  109.             sheet.setColumnWidth(1, 7000);
  110.  
  111.             //2º grupo de linhas
  112.             XSSFRow cabRowLinha2 = sheet.createRow(2);
  113.             for (int i = 0; i <= 2; i++) {
  114.                 cabRowLinha2.createCell(i);
  115.  
  116.             }
  117.  
  118.             XSSFCell cellA3 = cabRowLinha2.getCell(0);
  119.             cellA3.setCellValue("Unimed 117: " + listaPagamento.getNomeOperadora());
  120.             cellA3.setCellStyle(estilo);
  121.             XSSFCell cellB3 = cabRowLinha2.getCell(1);
  122.             cellB3.setCellValue("Pagamento: " + listaPagamento.getDataCompetencia());
  123.             cellB3.setCellStyle(estilo);
  124.             //Linha 4
  125.             XSSFRow cabRowLinha4 = sheet.createRow(4);
  126.             for (int i = 0; i <= 2; i++) {
  127.                 cabRowLinha4.createCell(i);
  128.  
  129.             }
  130.  
  131.             XSSFCell cellA4 = cabRowLinha4.getCell(0);
  132.             cellA4.setCellValue("DESCRIÇÃO");
  133.             cellA4.setCellStyle(styleTitle);
  134.  
  135.             XSSFCell cellB4 = cabRowLinha4.getCell(1);
  136.             cellB4.setCellValue("VALOR");
  137.             cellB4.setCellStyle(styleTitle);
  138.  
  139.             XSSFRow cabRowLinha5 = sheet.createRow(5);
  140.             for (int i = 0; i <= 2; i++) {
  141.                 cabRowLinha5.createCell(i);
  142.  
  143.             }
  144.             //PEGAR VALOR DO CRÉDITO LINHA = 5
  145.             XSSFCell cellA5 = cabRowLinha5.getCell(0);
  146.             cellA5.setCellValue("TOTAL CRÉDITOS");
  147.             cellA5.setCellStyle(styleTitle);
  148.  
  149.             XSSFCell cellB5 = cabRowLinha5.getCell(1);
  150.             BigDecimal big = listaPagamento.getValorCredito();
  151.  
  152.             cellB5.setCellValue(big.floatValue());
  153.             cellB5.setCellStyle(estilo);
  154.  
  155.             //For que pega lista e preenche campos  LISTA  LINHA = 7
  156.             int cont = 0;
  157.             for (int i = 0; i < ListaGuiaPag.size(); i++) {
  158.  
  159.                 XSSFRow cabRow7 = sheet.createRow(7 + i);
  160.                 for (int x = 0; x <= 2; x++) {
  161.                     cabRow7.createCell(x);
  162.                 }
  163.  
  164.                 XSSFCell cellA7 = cabRow7.getCell(0);
  165.                 cellA7.setCellValue(ListaGuiaPag.get(i).getDescricao());
  166.                 cellA7.setCellStyle(styleTitle);
  167.  
  168.                 XSSFCell cellB7 = cabRow7.getCell(1);
  169.                 cellB7.setCellStyle(estilo);
  170.  
  171.                 BigDecimal b = ListaGuiaPag.get(i).getValorDesconto();
  172.                 cellB7.setCellValue(b.floatValue());
  173.                 cont++;
  174.  
  175.             }
  176.             //For que pega lista e preenche campos  LISTA
  177.  
  178.             //Linha que pega a contagem + 8, vem logo após a lista
  179.             XSSFRow cabRowLinha9 = sheet.createRow(cont + 8);
  180.             for (int i = 0; i <= 2; i++) {
  181.                 cabRowLinha9.createCell(i);
  182.  
  183.             }
  184.             XSSFCell cellA9 = cabRowLinha9.getCell(0);
  185.             cellA9.setCellValue("TOTAL DÉBITOS");
  186.             cellA9.setCellStyle(styleTitle);
  187.  
  188.             XSSFCell cellB9 = cabRowLinha9.getCell(1);
  189.             cellB9.setCellStyle(cs2);
  190.  
  191.             BigDecimal valorTotalDesconto = listaPagamento.getTotalDescontos();
  192.             cellB9.setCellValue(valorTotalDesconto.floatValue());
  193.  
  194.             XSSFRow cabRowLinha10 = sheet.createRow(cont + 9);
  195.             for (int i = 0; i <= 2; i++) {
  196.                 cabRowLinha10.createCell(i);
  197.  
  198.             }
  199.  
  200.             //PEGAR VALOR DO CRÉDITO LINHA = 10
  201.             XSSFCell cellA10 = cabRowLinha10.getCell(0);
  202.             cellA10.setCellValue("TOTAL LÍQUIDO");
  203.             cellA10.setCellStyle(estilo);
  204.  
  205.             XSSFCell cellB10 = cabRowLinha10.getCell(1);
  206.             cellB10.setCellStyle(style);
  207.             BigDecimal valorTotal = listaPagamento.getTotal();
  208.             cellB10.setCellValue(valorTotal.floatValue());
  209.  
  210.             XSSFRow cabRowLinha11 = sheet.createRow(cont + 11);
  211.             for (int i = 0; i <= 2; i++) {
  212.                 cabRowLinha11.createCell(i);
  213.  
  214.             }
  215.  
  216.             //PEGAR VALOR DO CRÉDITO LINHA = 10
  217.             XSSFCell cellA11 = cabRowLinha11.getCell(0);
  218.             cellA11.setCellValue("INSS PESSOA JURÍDICA");
  219.             cellA11.setCellStyle(estilo);
  220.  
  221.             XSSFCell cellB11 = cabRowLinha11.getCell(1);
  222.             cellB11.setCellStyle(estilo);
  223.             cellB11.setCellValue(listaPagamento.getInssPJ());
  224.  
  225.             XSSFRow cabRowLinha12 = sheet.createRow(cont + 12);
  226.             for (int i = 0; i <= 2; i++) {
  227.                 cabRowLinha12.createCell(i);
  228.  
  229.             }
  230.  
  231.             //PEGAR VALOR DO CRÉDITO LINHA = 10
  232.             XSSFCell cellA12 = cabRowLinha12.getCell(0);
  233.             cellA12.setCellValue("INSS PESSOA JURÍDICA");
  234.             cellA12.setCellStyle(estilo);
  235.  
  236.             XSSFCell cellB12 = cabRowLinha12.getCell(1);
  237.             cellB12.setCellStyle(estilo);
  238.             cellB12.setCellValue(listaPagamento.getInssPF());
  239.  
  240.             /*-----------------------GUIA ANALITICO*-----------------------*/
  241.             /*-----------------------GUIA ANALITICO*-----------------------*/
  242.             XSSFCellStyle estiloS1 = wb.createCellStyle();
  243.             XSSFDataFormat format1 = wb.createDataFormat();
  244.             estiloS1.setDataFormat(format1.getFormat("R$#,##0.00_);(R$#,##0.00)"));
  245.             estiloS1.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  246.             estiloS1.setFont(negrito);
  247.             estiloS1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  248.             estiloS1.setBorderTop(HSSFCellStyle.BORDER_THIN);
  249.             estiloS1.setBorderRight(HSSFCellStyle.BORDER_THIN);
  250.             estiloS1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  251.  
  252.             XSSFCellStyle estiloS3 = wb.createCellStyle();
  253.             estiloS3.setDataFormat(format1.getFormat("R$#,##0.00_);(R$#,##0.00)"));
  254.             estiloS3.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  255.             estiloS3.setFont(negrito);
  256.             estiloS3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  257.             estiloS3.setBorderTop(HSSFCellStyle.BORDER_THIN);
  258.             estiloS3.setBorderRight(HSSFCellStyle.BORDER_THIN);
  259.             estiloS3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  260.  
  261.             XSSFCellStyle estiloS2 = wb.createCellStyle();
  262.             estiloS2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
  263.             estiloS2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  264.             estiloS2.setBorderTop(HSSFCellStyle.BORDER_THIN);
  265.             estiloS2.setBorderRight(HSSFCellStyle.BORDER_THIN);
  266.             estiloS2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  267.  
  268.             XSSFRow titulo = sheet1.createRow(0);
  269.  
  270.             for (int i = 0; i <= 12; i++) {
  271.                 titulo.createCell(i);
  272.             }
  273.             //Mescla as celulas do titulo
  274.             sheet1.addMergedRegion(CellRangeAddress.valueOf("$A$1:$M$1"));
  275.             XSSFCell tituloAnalitico = titulo.getCell(0);
  276.             tituloAnalitico.setCellStyle(styleTitle);
  277.  
  278.             tituloAnalitico.setCellValue("Analítico");
  279.  
  280.             //1º Grupo de linhas Analitico
  281.             XSSFRow cabRowAnalitico1 = sheet1.createRow(1);
  282.             for (int i = 0; i <= 12; i++) {
  283.                 cabRowAnalitico1.createCell(i);
  284.  
  285.             }
  286. //            XSSFCell AnaA2 = cabRowAnalitico1.getCell(0);
  287. //            AnaA2.setCellStyle(estiloS1);
  288. //            AnaA2.setCellValue("Numero do Lote");
  289. //
  290. //            XSSFCell AnaB2 = cabRowAnalitico1.getCell(1);
  291. //            AnaB2.setCellStyle(estiloS1);
  292. //            AnaB2.setCellValue(listaLote.getNumeroLote());
  293.  
  294.             //2º Grupo de linhas analitico
  295.             XSSFRow cabRowAnalitico2 = sheet1.createRow(2);
  296.             for (int i = 0; i <= 12; i++) {
  297.                 cabRowAnalitico2.createCell(i);
  298.  
  299.             }
  300.             XSSFCell AnaA3 = cabRowAnalitico2.getCell(0);
  301.             AnaA3.setCellStyle(estiloS3);
  302.             AnaA3.setCellValue("Prestador Executante: " + listaPagamento.getNomePrestador() + " " + listaPagamento.getCodigoPrestador());
  303.             sheet1.addMergedRegion(CellRangeAddress.valueOf("$A$3:$M$3"));
  304.  
  305.             //3º Grupo de linhas analitico, cabeçalho
  306.             XSSFRow cabRowAnalitico3 = sheet1.createRow(3);
  307.             for (int i = 0; i <= 12; i++) {
  308.                 cabRowAnalitico3.createCell(i);
  309.  
  310.             }
  311.             XSSFCell AnaA4 = cabRowAnalitico3.getCell(0);
  312.             AnaA4.setCellStyle(estiloS1);
  313.             AnaA4.setCellValue("Nº Doc");
  314.             sheet1.setColumnWidth(0, 5300);
  315.  
  316.             XSSFCell AnaB4 = cabRowAnalitico3.getCell(1);
  317.             AnaB4.setCellStyle(estiloS1);
  318.             AnaB4.setCellValue("Código");
  319.             sheet1.setColumnWidth(1, 4300);
  320.  
  321.             XSSFCell AnaC4 = cabRowAnalitico3.getCell(2);
  322.             AnaC4.setCellStyle(estiloS1);
  323.             AnaC4.setCellValue("Usuário");
  324.             sheet1.setColumnWidth(2, 12000);
  325.  
  326.             XSSFCell AnaD4 = cabRowAnalitico3.getCell(3);
  327.             AnaD4.setCellStyle(estiloS1);
  328.             AnaD4.setCellValue("Data");
  329.             sheet1.setColumnWidth(3, 2800);
  330.  
  331.             XSSFCell AnaE4 = cabRowAnalitico3.getCell(4);
  332.             AnaE4.setCellStyle(estiloS1);
  333.             AnaE4.setCellValue("Proced.");
  334.             sheet1.setColumnWidth(4, 2500);
  335.  
  336.             XSSFCell AnaF4 = cabRowAnalitico3.getCell(5);
  337.             AnaF4.setCellStyle(estiloS1);
  338.             AnaF4.setCellValue("Tabela");
  339.             sheet1.setColumnWidth(5, 3800);
  340.  
  341.             XSSFCell AnaG4 = cabRowAnalitico3.getCell(6);
  342.             AnaG4.setCellStyle(estiloS1);
  343.             AnaG4.setCellValue("Descrição do Proced.");
  344.             sheet1.setColumnWidth(6, 10000);
  345.  
  346.             XSSFCell AnaH4 = cabRowAnalitico3.getCell(7);
  347.             AnaH4.setCellStyle(estiloS1);
  348.             AnaH4.setCellValue("Qtd.");
  349.             sheet1.setColumnWidth(7, 1200);
  350.  
  351.             XSSFCell AnaI4 = cabRowAnalitico3.getCell(8);
  352.             AnaI4.setCellStyle(estiloS1);
  353.             AnaI4.setCellValue("Filme");
  354.             sheet1.setColumnWidth(8, 2500);
  355.  
  356.             XSSFCell AnaJ4 = cabRowAnalitico3.getCell(9);
  357.             AnaJ4.setCellStyle(estiloS1);
  358.             AnaJ4.setCellValue("Custo");
  359.             sheet1.setColumnWidth(9, 2500);
  360.  
  361.             XSSFCell AnaK4 = cabRowAnalitico3.getCell(10);
  362.             AnaK4.setCellStyle(estiloS1);
  363.             AnaK4.setCellValue("Hono");
  364.             sheet1.setColumnWidth(10, 2500);
  365.  
  366.             XSSFCell AnaL4 = cabRowAnalitico3.getCell(11);
  367.             AnaL4.setCellStyle(estiloS1);
  368.             AnaL4.setCellValue("Valor");
  369.             sheet1.setColumnWidth(11, 3000);
  370.  
  371.             XSSFCell AnaL5 = cabRowAnalitico3.getCell(12);
  372.             AnaL5.setCellStyle(estiloS1);
  373.             AnaL5.setCellValue("Numero do Lote");
  374.             sheet1.setColumnWidth(12, 4200);
  375.  
  376.             //Percorre a lista e preenche as celulas
  377.             int cont2 = 0;
  378.             for (int i = 0; i < listaContatoslt.size(); i++) {
  379.  
  380.                 XSSFRow cabRowAnalitico7 = sheet1.createRow(i + 4);
  381.                 for (int x = 0; x <= 12; x++) {
  382.                     cabRowAnalitico7.createCell(x);
  383.                 }
  384.  
  385.                 XSSFCell cellAnaA5 = cabRowAnalitico7.getCell(0);
  386.                 cellAnaA5.setCellStyle(estiloS2);
  387.                 cellAnaA5.setCellValue(listaContatoslt.get(i).getNumeroDocumento());
  388.  
  389.                 XSSFCell cellAnaB5 = cabRowAnalitico7.getCell(1);
  390.                 cellAnaB5.setCellStyle(estiloS2);
  391.                 cellAnaB5.setCellValue(listaContatoslt.get(i).getCodigo());
  392.  
  393.                 XSSFCell cellAnaC5 = cabRowAnalitico7.getCell(2);
  394.                 cellAnaC5.setCellStyle(estiloS2);
  395.                 cellAnaC5.setCellValue(listaContatoslt.get(i).getNomeBeneficiario());
  396.  
  397.                 XSSFCell cellAnaD5 = cabRowAnalitico7.getCell(3);
  398.                 cellAnaD5.setCellStyle(estiloS2);
  399.                 cellAnaD5.setCellValue(listaContatoslt.get(i).getData());
  400.  
  401.                 XSSFCell cellAnaE5 = cabRowAnalitico7.getCell(4);
  402.                 cellAnaE5.setCellStyle(estiloS2);
  403.                 cellAnaE5.setCellValue(listaContatoslt.get(i).getProcedimento());
  404.  
  405.                 XSSFCell cellAnaF5 = cabRowAnalitico7.getCell(5);
  406.                 cellAnaF5.setCellStyle(estiloS2);
  407.                 cellAnaF5.setCellValue("Outras Tabelas");
  408.  
  409.                 XSSFCell cellAnaG5 = cabRowAnalitico7.getCell(6);
  410.                 cellAnaG5.setCellStyle(estiloS2);
  411.                 cellAnaG5.setCellValue(listaContatoslt.get(i).getDescricaoProced());
  412.  
  413.                 XSSFCell cellAnaH5 = cabRowAnalitico7.getCell(7);
  414.                 cellAnaH5.setCellStyle(estiloS2);
  415.                 cellAnaH5.setCellValue(listaContatoslt.get(i).getQtdExecutada());
  416.  
  417.                 XSSFCell cellAnaI5 = cabRowAnalitico7.getCell(8);
  418.                 cellAnaI5.setCellStyle(estiloS1);
  419.                 BigDecimal valorfilme = listaContatoslt.get(i).getCustoFilme();
  420.                 cellAnaI5.setCellValue(valorfilme.floatValue());
  421.  
  422.                 XSSFCell cellAnaJ5 = cabRowAnalitico7.getCell(9);
  423.                 cellAnaJ5.setCellStyle(estiloS1);
  424.                 BigDecimal valorServ = listaContatoslt.get(i).getCustoServico();
  425.                 cellAnaJ5.setCellValue(valorServ.floatValue());
  426.  
  427.                 XSSFCell cellAnaK5 = cabRowAnalitico7.getCell(10);
  428.                 cellAnaK5.setCellStyle(estiloS1);
  429.                 BigDecimal valorHono = listaContatoslt.get(i).getHonorario();
  430.                 cellAnaK5.setCellValue(valorHono.floatValue());
  431.  
  432. //                if (listaContatoslt.get(i).getTipoGlosa() != null) {
  433. //                    XSSFCell cellAnaL5 = cabRowAnalitico7.getCell(11);
  434. //                    cellAnaL5.setCellStyle(estiloS1);
  435. //                    float xxx = 0f;
  436. //                    cellAnaL5.setCellValue(xxx);
  437. //                } else {
  438.                 XSSFCell cellAnaL5 = cabRowAnalitico7.getCell(11);
  439.                 cellAnaL5.setCellStyle(estiloS1);
  440.                 BigDecimal valort = listaContatoslt.get(i).getValorTotalInformado();
  441.                 cellAnaL5.setCellValue(valort.floatValue());
  442.  
  443. //                }
  444.                 XSSFCell cellAnaE12 = cabRowAnalitico7.getCell(12);
  445.                 cellAnaE12.setCellStyle(estiloS1);
  446.                 cellAnaE12.setCellValue(listaContatoslt.get(i).getNumLote());
  447.  
  448.                 cont2++;
  449.             }
  450.  
  451.             XSSFRow cabRowLinha8 = sheet1.createRow((cont2 * 1) + 8);
  452.             for (int i = 0; i <= 12; i++) {
  453.                 cabRowLinha8.createCell(i);
  454.  
  455.             }
  456.             XSSFCell cellAnaA8 = cabRowLinha8.getCell(0);
  457.             cellAnaA8.setCellStyle(estiloS1);
  458.             cellAnaA8.setCellValue("TOTAL DO PRESTADOR");
  459.  
  460.             XSSFCell cellAnaB8 = cabRowLinha8.getCell(12);
  461.             BigDecimal valorLiberadoGeral = listaCabecalho.getValorLiberadoGeral();
  462.             cellAnaB8.setCellStyle(estiloS1);
  463.             cellAnaB8.setCellValue(valorLiberadoGeral.floatValue());
  464.  
  465.             XSSFRow cabRowLinha13 = sheet1.createRow((cont2 * 1) + 9);
  466.             for (int i = 0; i <= 12; i++) {
  467.                 cabRowLinha13.createCell(i);
  468.  
  469.             }
  470.             XSSFCell cellAnaA13 = cabRowLinha13.getCell(0);
  471.             cellAnaA13.setCellStyle(estiloS1);
  472.             cellAnaA13.setCellValue("TOTAL DO LOTE");
  473.  
  474.             XSSFCell cellAnaB13 = cabRowLinha13.getCell(12);
  475.             BigDecimal valorProtocolo = listaCabecalho.getValorLiberadoGeral();
  476.             cellAnaB13.setCellStyle(estiloS1);
  477.             cellAnaB13.setCellValue(valorProtocolo.floatValue());
  478.  
  479.             /*-----------------------GUIA ANALITICO*-----------------------*/
  480.             /*-----------------------GUIA ANALITICO*-----------------------*/
  481.             /*-----------------------GUIA GLOSA*-----------------------*/
  482.             /*-----------------------GUIA GLOSA*-----------------------*/
  483.             //1º Grupo de linhas Glosa, cabeçalho
  484.             XSSFRow cabRowGlosa00 = sheet2.createRow(0);
  485.             for (int i = 0; i <= 10; i++) {
  486.                 cabRowGlosa00.createCell(i);
  487.  
  488.             }
  489.             XSSFCell cellGlosaA0 = cabRowGlosa00.getCell(0);
  490.             cellGlosaA0.setCellStyle(estiloS1);
  491.             cellGlosaA0.setCellValue("Nº Doc");
  492.             sheet2.setColumnWidth(0, 5300);
  493.  
  494.             XSSFCell cellGlosaB0 = cabRowGlosa00.getCell(1);
  495.             cellGlosaB0.setCellStyle(estiloS1);
  496.             cellGlosaB0.setCellValue("Código");
  497.             sheet2.setColumnWidth(1, 4300);
  498.  
  499.             XSSFCell cellGlosaC0 = cabRowGlosa00.getCell(2);
  500.             cellGlosaC0.setCellStyle(estiloS1);
  501.             cellGlosaC0.setCellValue("USUÁRIO");
  502.             sheet2.setColumnWidth(2, 10000);
  503.  
  504.             XSSFCell cellGlosaD0 = cabRowGlosa00.getCell(3);
  505.             cellGlosaD0.setCellStyle(estiloS1);
  506.             cellGlosaD0.setCellValue("DATA");
  507.             sheet2.setColumnWidth(3, 3200);
  508.  
  509.             XSSFCell cellGlosaE0 = cabRowGlosa00.getCell(4);
  510.             cellGlosaE0.setCellStyle(estiloS1);
  511.             cellGlosaE0.setCellValue("PROCED.");
  512.             sheet2.setColumnWidth(4, 3000);
  513.  
  514.             XSSFCell cellGlosaF0 = cabRowGlosa00.getCell(5);
  515.             cellGlosaF0.setCellStyle(estiloS1);
  516.             cellGlosaF0.setCellValue("TABELA");
  517.             sheet2.setColumnWidth(5, 4300);
  518.  
  519.             XSSFCell cellGlosaG0 = cabRowGlosa00.getCell(6);
  520.             cellGlosaG0.setCellStyle(estiloS1);
  521.             cellGlosaG0.setCellValue("DESCRIÇÃO DO PROCED.");
  522.             sheet2.setColumnWidth(6, 8000);
  523.  
  524.             XSSFCell cellGlosaH0 = cabRowGlosa00.getCell(7);
  525.             cellGlosaH0.setCellStyle(estiloS1);
  526.             cellGlosaH0.setCellValue("QTD.");
  527.             sheet2.setColumnWidth(7, 2000);
  528.  
  529.             XSSFCell cellGlosaI0 = cabRowGlosa00.getCell(8);
  530.             cellGlosaI0.setCellStyle(estiloS1);
  531.             cellGlosaI0.setCellValue("TIPO");
  532.             sheet2.setColumnWidth(8, 2000);
  533.  
  534.             XSSFCell cellGlosaJ0 = cabRowGlosa00.getCell(9);
  535.             cellGlosaJ0.setCellStyle(estiloS1);
  536.             cellGlosaJ0.setCellValue("MOTIVO");
  537.             sheet2.setColumnWidth(9, 7300);
  538.  
  539.             XSSFCell cellGlosaK0 = cabRowGlosa00.getCell(10);
  540.             cellGlosaK0.setCellStyle(estiloS1);
  541.             cellGlosaK0.setCellValue("VALOR");
  542.             sheet2.setColumnWidth(10, 3200);
  543.             int contGlosa = 0;
  544.             int contGlosa1 = 0;
  545.  
  546.             int tam = 0;
  547.             for (int i = 0; i < listaGlosa.size(); i++) {
  548.                 XSSFRow cabRowGlosa = sheet2.createRow(1 + i);
  549.                 tam = 1 + i;
  550.  
  551.                 for (int x = 0; x <= 10; x++) {
  552.                     cabRowGlosa.createCell(x);
  553.                 }
  554.  
  555.                 XSSFCell cellGlosaA1 = cabRowGlosa.getCell(0);
  556.                 cellGlosaA1.setCellStyle(estiloS2);
  557.                 cellGlosaA1.setCellValue(listaGlosa.get(i).getCodigo());
  558.  
  559.                 XSSFCell cellGlosaB2 = cabRowGlosa.getCell(1);
  560.                 cellGlosaB2.setCellStyle(estiloS2);
  561.                 cellGlosaB2.setCellValue(listaGlosa.get(i).getNumeroDocumento());
  562.  
  563.                 XSSFCell cellGlosaC2 = cabRowGlosa.getCell(2);
  564.                 cellGlosaC2.setCellStyle(estiloS2);
  565.                 cellGlosaC2.setCellValue(listaGlosa.get(i).getNomeBeneficiario());
  566.  
  567.                 XSSFCell cellGlosaD2 = cabRowGlosa.getCell(3);
  568.                 cellGlosaD2.setCellStyle(estiloS2);
  569.                 cellGlosaD2.setCellValue(listaGlosa.get(i).getData());
  570.  
  571.                 XSSFCell cellGlosaE2 = cabRowGlosa.getCell(4);
  572.                 cellGlosaE2.setCellStyle(estiloS2);
  573.                 cellGlosaE2.setCellValue(listaGlosa.get(i).getProcedimento());
  574.  
  575.                 XSSFCell cellGlosaG2 = cabRowGlosa.getCell(5);
  576.                 cellGlosaG2.setCellStyle(estiloS2);
  577.                 cellGlosaG2.setCellValue("Outras Tabelas");
  578.  
  579.                 XSSFCell cellGlosaF2 = cabRowGlosa.getCell(6);
  580.                 cellGlosaF2.setCellStyle(estiloS2);
  581.                 cellGlosaF2.setCellValue(listaGlosa.get(i).getDescricaoProced());
  582.  
  583.                 XSSFCell cellGlosaH2 = cabRowGlosa.getCell(7);
  584.                 cellGlosaH2.setCellStyle(estiloS2);
  585.                 cellGlosaH2.setCellValue(listaGlosa.get(i).getQtdExecutada());
  586.  
  587.                 XSSFCell cellGlosaI2 = cabRowGlosa.getCell(8);
  588.                 cellGlosaI2.setCellStyle(estiloS2);
  589.                 cellGlosaI2.setCellValue(listaGlosa.get(i).getTipoGlosa());
  590.  
  591.                 XSSFCell cellGlosaJ2 = cabRowGlosa.getCell(9);
  592.                 cellGlosaJ2.setCellStyle(estiloS2);
  593.                 cellGlosaJ2.setCellValue(listaGlosa.get(i).getDescGlosa());
  594.  
  595.                 XSSFCell cellGlosaK2 = cabRowGlosa.getCell(10);
  596.                 BigDecimal valorGlosa = listaGlosa.get(i).getValorGlosa();
  597.                 cellGlosaK2.setCellStyle(estiloS1);
  598.                 cellGlosaK2.setCellValue(valorGlosa.floatValue());
  599.                 contGlosa++;
  600.  
  601.                 contGlosa1++;
  602.  
  603.             }
  604.  
  605.             XSSFRow cabRowGlosa3 = sheet2.createRow(tam + 2);
  606.             for (int i = 0; i <= 10; i++) {
  607.                 cabRowGlosa3.createCell(i);
  608.  
  609.             }
  610.  
  611.             XSSFCell cellGlosaL2 = cabRowGlosa3.getCell(0);
  612.             cellGlosaL2.setCellStyle(estiloS1);
  613.             cellGlosaL2.setCellValue("TOTAL:");
  614.  
  615.             XSSFCell cellAnaM8 = cabRowGlosa3.getCell(10);
  616.             BigDecimal valorGlosaTotal = listaCabecalho.getValorGlosaGeral();
  617.             cellAnaM8.setCellStyle(estiloS1);
  618.             cellAnaM8.setCellValue(valorGlosaTotal.floatValue());
  619.  
  620.  
  621.             /*-----------------------GUIA GLOSA*-----------------------*/
  622.             /*-----------------------GUIA GLOSA*-----------------------*/
  623.             wb.write(out);
  624.             out.close();
  625.         } catch (IOException ex) {
  626.             Logger.getLogger(RelatorioExcel.class.getName()).log(Level.SEVERE, null, ex);
  627.         }
  628.  
  629.         return caminho;
  630.     }
  631.  
  632. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement