List of usage examples for org.apache.poi.xssf.usermodel XSSFWorkbook write
@SuppressWarnings("resource") public final void write(OutputStream stream) throws IOException
From source file:com.accenture.control.ExtraiPlanilha.java
public static void gravaCTPlanilha(List<Plano> plano, String panilha, int linhaCelula) throws FileNotFoundException, IOException, InvalidFormatException, SQLException, ClassNotFoundException {/*from w ww . j a v a 2 s. com*/ ManipulaDadosSQLite banco = new ManipulaDadosSQLite(); //recebe a planilha e atribui a variavel arquivo FileInputStream arquivo = new FileInputStream(new File(panilha)); System.out.println(panilha); //instacia um workbook passando arquivo como paramentro XSSFWorkbook workbook = new XSSFWorkbook(arquivo); XSSFSheet sheetPlano = workbook.getSheetAt(1); String cadeia = "B", segmento = "C", produto = "D", funcionalidade = "E", cenarioItegrado = "F", sistemaMaster = "G", sistemasEnvolvidos = "H", fornecedor = "I", tpRequisito = "J", requisito = "K", cenarioTeste = "L", casoTeste = "M", descricao = "N", nomeStep = "P", descricaoStep = "Q", resultadoEsperado = "R", cenarioAuto = "U", type = "V", trg = "W", subject = "X", criacao = "Y"; CellReference cellReference = new CellReference("B8"); // Row row = sheetPlano.getRow(cellReference.getRow()); // Cell cell = row.getCell(cellReference.getCol()); int tamanhoLista = plano.size(); int numeroCelula = 8; int linha = linhaCelula; int celula = 12; Row row = sheetPlano.getRow(linha); Cell cell;//= row.getCell(celula); Cell celCadeia = row.getCell(1); Cell celSegmento = row.getCell(2); Cell celProduto = row.getCell(3); Cell celFuncionalidade = row.getCell(4); Cell celCenarioIntegracao = row.getCell(5); Cell celSistemaMaster = row.getCell(6); Cell celSistemaEnvolvidos = row.getCell(7); Cell celFornecedor = row.getCell(8); Cell celTpRequisito = row.getCell(9); Cell celRequisito = row.getCell(10); Cell celCenario = row.getCell(11); Cell celCasoTeste = row.getCell(12); Cell celDescricao = row.getCell(13); Cell celQtdSistemas = row.getCell(19); Cell celCenarioAuto = row.getCell(21); Cell celType = row.getCell(22); Cell celTrg = row.getCell(23); Cell celSubject = row.getCell(24); Cell celCriacao = row.getCell(25); Cell celStep = row.getCell(16); Step steps = new Step(); for (int i = 0; i < tamanhoLista; i++) { row = sheetPlano.getRow(linha); celCadeia = row.getCell(1); celSegmento = row.getCell(2); celProduto = row.getCell(3); celFuncionalidade = row.getCell(4); celCenarioIntegracao = row.getCell(5); celSistemaMaster = row.getCell(6); celSistemaEnvolvidos = row.getCell(7); celFornecedor = row.getCell(8); celTpRequisito = row.getCell(9); celRequisito = row.getCell(10); celCenario = row.getCell(11); celCasoTeste = row.getCell(12); celDescricao = row.getCell(13); Cell celComplexidade = row.getCell(15); celQtdSistemas = row.getCell(19); Cell celQtdStep = row.getCell(20); celCenarioAuto = row.getCell(21); celType = row.getCell(22); celTrg = row.getCell(23); celSubject = row.getCell(24); celCriacao = row.getCell(25); celCadeia.setCellValue(plano.get(i).getCadeia()); celSegmento.setCellValue(plano.get(i).getSegmento()); celProduto.setCellValue(plano.get(i).getProduto()); celFuncionalidade.setCellValue(plano.get(i).getFuncionalidade()); celCenarioIntegracao.setCellValue(plano.get(i).getCenarioIntegrado()); celSistemaMaster.setCellValue(plano.get(i).getSistemaMaster()); celSistemaEnvolvidos.setCellValue(plano.get(i).getSistemasEnvolvidos()); celFornecedor.setCellValue(plano.get(i).getFornecedor()); celTpRequisito.setCellValue(plano.get(i).getTpRequisito()); celRequisito.setCellValue(plano.get(i).getRequisito()); celCenario.setCellValue(plano.get(i).getCenarioTeste()); celCasoTeste.setCellValue(plano.get(i).getCasoTeste()); celDescricao.setCellValue(plano.get(i).getDescCasoTeste()); String formulaComplexibilidade = celComplexidade.getCellFormula(); celComplexidade.setCellFormula(formulaComplexibilidade); celQtdSistemas.setCellValue(plano.get(i).getQtdSistemas()); String formulaQtdStep = celQtdStep.getCellFormula(); celQtdStep.setCellFormula(formulaQtdStep); celCenarioAuto.setCellValue(plano.get(i).getCenarioAutomatizavel()); celType.setCellValue(plano.get(i).getType()); celTrg.setCellValue(plano.get(i).getTrg()); celSubject.setCellValue(plano.get(i).getSubject()); celCriacao.setCellValue(plano.get(i).getCriacaoAlteracao()); celStep = row.getCell(16); row = sheetPlano.getRow(linha); // celCasoTeste = row.getCell(12); int linhaStep = linha; List<Plano> listPlanos = banco.selectPlanoPorId(plano.get(i)); List<Step> listStep = banco.getStepPorPlano(plano.get(i)); int linhaLimpeza = linha; //limpa as clulas de step for (int cont = 0; cont <= 24; cont++) { Cell celNomeStep = row.getCell(16); Cell celDescStep = row.getCell(17); Cell celResultadoStep = row.getCell(18); String valor = null; celNomeStep.setCellValue(valor); celDescStep.setCellValue(valor); celResultadoStep.setCellValue(valor); linhaLimpeza = linhaLimpeza + 1; row = sheetPlano.getRow(linhaLimpeza); } //fim row = sheetPlano.getRow(linha); int tamanho = listStep.size(); int idTemp = 0; for (int cont = 0; cont < tamanho; cont++) { // if(idTemp != listPlanos.get(cont).getStep().getId()){ // model.addRow(new String[]{String.valueOf(listPlanos.get(cont).getStep().getNomeStep()), listPlanos.get(cont).getStep().getDescStep(), // listPlanos.get(cont).getStep().getResultadoStep(), String.valueOf(listPlanos.get(cont).getStep().getId())}); // } Cell celNomeStep = row.getCell(16); Cell celDescStep = row.getCell(17); Cell celResultadoStep = row.getCell(18); celNomeStep.setCellValue(listStep.get(cont).getNomeStep()); celDescStep.setCellValue(listStep.get(cont).getDescStep()); celResultadoStep.setCellValue(listStep.get(cont).getResultadoStep()); //caso o ct seja alterao pinta os steps de amarelo - inicio if (plano.get(i).getCriacaoAlteracao().equals("Alterao")) { Color color = new XSSFColor(java.awt.Color.yellow); // XSSFCellStyle style = workbook.createCellStyle(); // style.setBorderTop((short) 6); // double lines border // style.setBorderBottom((short) 1); // single line border // style.setFillBackgroundColor(IndexedColors.YELLOW.getIndex()); // // celNomeStep.setCellStyle(style); } //fim linhaStep = linhaStep + 1; row = sheetPlano.getRow(linhaStep); celStep = row.getCell(16); idTemp = listPlanos.get(cont).getId(); } linha = linha + 25; row = sheetPlano.getRow(linha); cell = celCadeia; } FileOutputStream fileOut = new FileOutputStream(new File(panilha)); workbook.write(fileOut); fileOut.close(); }
From source file:com.accenture.control.ExtraiPlanilha.java
public void exportTStoTI(List<TesteCaseTSBean> testCases, String planilha) throws FileNotFoundException, IOException, InvalidFormatException, SQLException, ClassNotFoundException { copySheet(new File("C:\\FastPlan\\sheets\\TI.xlsx"), new File(planilha)); //recebe a planilha e atribui a variavel arquivo FileInputStream arquivo = new FileInputStream(new File(planilha)); System.out.println(planilha); //instacia um workbook passando arquivo como paramentro XSSFWorkbook workbook = new XSSFWorkbook(arquivo); XSSFSheet sheetPlano = workbook.getSheetAt(1); // Row row = sheetPlano.getRow(cellReference.getRow()); // Cell cell = row.getCell(cellReference.getCol()); int tamanhoLista = testCases.size(); int numeroCelula = 8; int linha = 7; int celula = 12; Row row = sheetPlano.getRow(linha);/*ww w . j a v a 2s.com*/ Cell cell;//= row.getCell(celula); Cell celCadeia = row.getCell(1); Cell celSegmento = row.getCell(2); Cell celProduto = row.getCell(3); Cell celFuncionalidade = row.getCell(4); Cell celCenarioIntegracao = row.getCell(5); Cell celSistemaMaster = row.getCell(6); Cell celSistemaEnvolvidos = row.getCell(7); Cell celFornecedor = row.getCell(8); Cell celTpRequisito = row.getCell(9); Cell celRequisito = row.getCell(10); Cell celCenario = row.getCell(11); Cell celCasoTeste = row.getCell(12); Cell celDescricao = row.getCell(13); Cell celQtdSistemas = row.getCell(19); Cell celCenarioAuto = row.getCell(21); Cell celType = row.getCell(22); Cell celTrg = row.getCell(23); Cell celSubject = row.getCell(24); Cell celCriacao = row.getCell(25); Cell celStep = row.getCell(16); Step steps = new Step(); for (int i = 0; i < tamanhoLista; i++) { testCases.get(i) .setTestScriptName(testCases.get(i).getTestScriptName().replaceAll("\\d\\d.\\d\\d-", "")); for (int j = 0; j < testCases.get(i).getParameters().size(); j++) { if (testCases.get(i).getTestScriptDescription() .contains(testCases.get(i).getParameters().get(j).getParameterValue())) { testCases.get(i) .setTestScriptDescription(testCases.get(i).getTestScriptDescription().replace( "<" + testCases.get(i).getParameters().get(j).getParameterValue() + ">", "<<<" + testCases.get(i).getParameters().get(j).getParameterName() + ">>>")); } } row = sheetPlano.getRow(linha); celCadeia = row.getCell(1); celSegmento = row.getCell(2); celProduto = row.getCell(3); celFuncionalidade = row.getCell(4); celCenarioIntegracao = row.getCell(5); celSistemaMaster = row.getCell(6); celSistemaEnvolvidos = row.getCell(7); celFornecedor = row.getCell(8); celTpRequisito = row.getCell(9); celRequisito = row.getCell(10); celCenario = row.getCell(11); celCasoTeste = row.getCell(12); celDescricao = row.getCell(13); Cell celComplexidade = row.getCell(15); celQtdSistemas = row.getCell(19); Cell celQtdStep = row.getCell(20); celCenarioAuto = row.getCell(21); celType = row.getCell(22); celTrg = row.getCell(23); celSubject = row.getCell(24); celCriacao = row.getCell(25); celCadeia.setCellValue(""); celSegmento.setCellValue(""); celProduto.setCellValue(""); celFuncionalidade.setCellValue(""); celCenarioIntegracao.setCellValue(""); celSistemaMaster.setCellValue(testCases.get(i).getProduct()); celSistemaEnvolvidos.setCellValue(testCases.get(i).getProduct()); celFornecedor.setCellValue("Accenture"); celTpRequisito.setCellValue(""); celRequisito.setCellValue(""); celCenario.setCellValue(testCases.get(i).getTestScriptName()); celCasoTeste.setCellValue(testCases.get(i).getTestScriptName()); celDescricao.setCellValue(testCases.get(i).getTestScriptDescription()); String formulaComplexibilidade = celComplexidade.getCellFormula(); celComplexidade.setCellFormula(formulaComplexibilidade); celQtdSistemas.setCellValue(1); String formulaQtdStep = celQtdStep.getCellFormula(); celQtdStep.setCellFormula(formulaQtdStep); celCenarioAuto.setCellValue("Sim"); celType.setCellValue("Manual"); celTrg.setCellValue("No"); celSubject.setCellValue(""); celCriacao.setCellValue("Criao"); celStep = row.getCell(16); row = sheetPlano.getRow(linha); // celCasoTeste = row.getCell(12); int linhaStep = linha; row = sheetPlano.getRow(linha); int tamanho = testCases.get(i).getListStep().size(); int idTemp = 0; for (int cont = 0; cont < tamanho; cont++) { // if(idTemp != listPlanos.get(cont).getStep().getId()){ // model.addRow(new String[]{String.valueOf(listPlanos.get(cont).getStep().getNomeStep()), listPlanos.get(cont).getStep().getDescStep(), // listPlanos.get(cont).getStep().getResultadoStep(), String.valueOf(listPlanos.get(cont).getStep().getId())}); // } Cell celNomeStep = row.getCell(16); Cell celDescStep = row.getCell(17); Cell celResultadoStep = row.getCell(18); for (int j = 0; j < testCases.get(i).getParameters().size(); j++) { if (testCases.get(i).getListStep().get(cont).getDescStep() .contains(testCases.get(i).getParameters().get(j).getParameterValue())) { testCases.get(i).getListStep().get(cont) .setDescStep(testCases.get(i).getListStep().get(cont).getDescStep().replace( "<" + testCases.get(i).getParameters().get(j).getParameterValue() + ">", "<<<" + testCases.get(i).getParameters().get(j).getParameterName() + ">>>")); } if (testCases.get(i).getListStep().get(cont).getResultadoStep() .contains(testCases.get(i).getParameters().get(j).getParameterValue())) { testCases.get(i).getListStep().get(cont).setResultadoStep( testCases.get(i).getListStep().get(cont).getResultadoStep().replace( "<" + testCases.get(i).getParameters().get(j).getParameterValue() + ">", "<<<" + testCases.get(i).getParameters().get(j).getParameterName() + ">>>")); } } testCases.get(i).getListStep().get(cont).setNomeStep("Step " + (cont + 1)); celNomeStep.setCellValue(testCases.get(i).getListStep().get(cont).getNomeStep()); celDescStep.setCellValue(testCases.get(i).getListStep().get(cont).getDescStep()); celResultadoStep.setCellValue(testCases.get(i).getListStep().get(cont).getResultadoStep()); linhaStep = linhaStep + 1; row = sheetPlano.getRow(linhaStep); celStep = row.getCell(16); } linha = linha + 25; row = sheetPlano.getRow(linha); cell = celCadeia; } FileOutputStream fileOut = new FileOutputStream(new File(planilha)); workbook.write(fileOut); fileOut.close(); }
From source file:com.accenture.control.ExtraiPlanilha.java
/** * Mtodo para sobrescrever ct na planilha * com o ct existente em uma * determinada linha ser substituido */* w w w . j a v a 2 s . c om*/ * * @author Raphael Coelho * * @param Plano - objeto plano * @param String - caminho da planilha * @param int - nmero da linha que est o ct na planilha * * @return void * */ public static void gravaCTPlanilha(Plano plano, String panilha, int linhaCelula) throws FileNotFoundException, IOException, InvalidFormatException, SQLException, ClassNotFoundException { /** * Exemplo bsico de um comentrio em JavaDoc */ //recebe a planilha e atribui a variavel arquivo FileInputStream arquivo = new FileInputStream(new File(panilha)); System.out.println(panilha); //instacia um workbook passando arquivo como paramentro ManipulaDadosSQLite banco = new ManipulaDadosSQLite(); XSSFWorkbook workbook = new XSSFWorkbook(arquivo); XSSFSheet sheetPlano = workbook.getSheetAt(1); CellReference cellReference = new CellReference("B8"); // Row row = sheetPlano.getRow(cellReference.getRow()); // Cell cell = row.getCell(cellReference.getCol()); // int tamanhoLista = plano.size(); int numeroCelula = 8; int linha = linhaCelula; int celula = 12; Row row = sheetPlano.getRow(linha); Cell cell;//= row.getCell(celula); Cell celCadeia = row.getCell(1); Cell celSegmento = row.getCell(2); Cell celProduto = row.getCell(3); Cell celFuncionalidade = row.getCell(4); Cell celCenarioIntegracao = row.getCell(5); Cell celSistemaMaster = row.getCell(6); Cell celSistemaEnvolvidos = row.getCell(7); Cell celFornecedor = row.getCell(8); Cell celTpRequisito = row.getCell(9); Cell celRequisito = row.getCell(10); Cell celCenario = row.getCell(11); Cell celCasoTeste = row.getCell(12); Cell celDescricao = row.getCell(13); Cell celQtdSistemas = row.getCell(19); Cell celCenarioAuto = row.getCell(21); Cell celType = row.getCell(22); Cell celTrg = row.getCell(23); Cell celSubject = row.getCell(24); Cell celCriacao = row.getCell(25); Cell celStep = row.getCell(16); Step steps = new Step(); row = sheetPlano.getRow(linha); celCadeia = row.getCell(1); celSegmento = row.getCell(2); celProduto = row.getCell(3); celFuncionalidade = row.getCell(4); celCenarioIntegracao = row.getCell(5); celSistemaMaster = row.getCell(6); celSistemaEnvolvidos = row.getCell(7); celFornecedor = row.getCell(8); celTpRequisito = row.getCell(9); celRequisito = row.getCell(10); celCenario = row.getCell(11); celCasoTeste = row.getCell(12); celDescricao = row.getCell(13); Cell celComplexidade = row.getCell(15); celQtdSistemas = row.getCell(19); Cell celQtdStep = row.getCell(20); celCenarioAuto = row.getCell(21); celType = row.getCell(22); celTrg = row.getCell(23); celSubject = row.getCell(24); celCriacao = row.getCell(25); celCadeia.setCellValue(plano.getCadeia()); celSegmento.setCellValue(plano.getSegmento()); celProduto.setCellValue(plano.getProduto()); celFuncionalidade.setCellValue(plano.getFuncionalidade()); celCenarioIntegracao.setCellValue(plano.getCenarioIntegrado()); celSistemaMaster.setCellValue(plano.getSistemaMaster()); celSistemaEnvolvidos.setCellValue(plano.getSistemasEnvolvidos()); celFornecedor.setCellValue(plano.getFornecedor()); celTpRequisito.setCellValue(plano.getTpRequisito()); celRequisito.setCellValue(plano.getRequisito()); celCenario.setCellValue(plano.getCenarioTeste()); celCasoTeste.setCellValue(plano.getCasoTeste()); celDescricao.setCellValue(plano.getDescCasoTeste()); String formulaComplexibilidade = celComplexidade.getCellFormula(); celComplexidade.setCellFormula(formulaComplexibilidade); celQtdSistemas.setCellValue(plano.getQtdSistemas()); String formulaQtdStep = celQtdStep.getCellFormula(); celQtdStep.setCellFormula(formulaQtdStep); celCenarioAuto.setCellValue(plano.getCenarioAutomatizavel()); celType.setCellValue(plano.getType()); celTrg.setCellValue(plano.getTrg()); celSubject.setCellValue(plano.getSubject()); celCriacao.setCellValue(plano.getCriacaoAlteracao()); celStep = row.getCell(16); row = sheetPlano.getRow(linha); // celCasoTeste = row.getCell(12); int linhaStep = linha; List<Plano> listPlanos = banco.selectPlanoPorId(plano); List<Step> listStep = banco.getStepPorPlano(plano); int linhaLimpeza = linha; //limpa as clulas de step for (int cont = 0; cont <= 24; cont++) { Cell celNomeStep = row.getCell(16); Cell celDescStep = row.getCell(17); Cell celResultadoStep = row.getCell(18); String valor = null; celNomeStep.setCellValue(valor); celDescStep.setCellValue(valor); celResultadoStep.setCellValue(valor); linhaLimpeza = linhaLimpeza + 1; row = sheetPlano.getRow(linhaLimpeza); } //fim row = sheetPlano.getRow(linha); int tamanho = listStep.size(); int idTemp = 0; for (int cont = 0; cont < tamanho; cont++) { // if(idTemp != listPlanos.get(cont).getStep().getId()){ // model.addRow(new String[]{String.valueOf(listPlanos.get(cont).getStep().getNomeStep()), listPlanos.get(cont).getStep().getDescStep(), // listPlanos.get(cont).getStep().getResultadoStep(), String.valueOf(listPlanos.get(cont).getStep().getId())}); // } Cell celNomeStep = row.getCell(16); Cell celDescStep = row.getCell(17); Cell celResultadoStep = row.getCell(18); celNomeStep.setCellValue(listStep.get(cont).getNomeStep()); celDescStep.setCellValue(listStep.get(cont).getDescStep()); celResultadoStep.setCellValue(listStep.get(cont).getResultadoStep()); //caso o ct seja alterao pinta os steps de amarelo - inicio if (plano.getCriacaoAlteracao().equals("Alterao")) { Color color = new XSSFColor(java.awt.Color.yellow); // XSSFCellStyle style = workbook.createCellStyle(); // style.setBorderTop((short) 6); // double lines border // style.setBorderBottom((short) 1); // single line border // style.setFillBackgroundColor((XSSFColor) color); // // celNomeStep.setCellStyle(style); } //fim linhaStep = linhaStep + 1; row = sheetPlano.getRow(linhaStep); celStep = row.getCell(16); idTemp = listPlanos.get(cont).getId(); } linha = linha + 25; row = sheetPlano.getRow(linha); cell = celCadeia; FileOutputStream fileOut = new FileOutputStream(new File(panilha)); workbook.write(fileOut); fileOut.close(); }
From source file:com.accenture.ts.dao.TesteCaseTSDAO.java
public boolean newTsSheet(String pathSheet, String nameSheet, List<TesteCaseTSBean> listTestCase) throws FileNotFoundException, IOException { boolean sucess = false; destinationSheet = new File(pathSheet); destinationSheet.mkdirs();//from w ww .java2 s.c om destinationSheet = new File(pathSheet + "\\" + nameSheet); sourceStheet = new File(sheetDefault); copySheet(sourceStheet, destinationSheet); FileInputStream fileSheet = new FileInputStream(destinationSheet); XSSFWorkbook workbook = new XSSFWorkbook(fileSheet); XSSFSheet sheetTS = workbook.getSheetAt(0); XSSFDataFormat format = workbook.createDataFormat(); XSSFCellStyle estilo = workbook.createCellStyle(); // String formatData = "aaaa-mm-dd\"T12:00:00-03:00\""; int linha = 1; Row row = sheetTS.getRow(linha); Cell descriptionPlan = row.getCell(0); Cell prj = row.getCell(1); Cell fase = row.getCell(2); Cell testPhase = row.getCell(3); Cell testScriptName = row.getCell(4); Cell testScriptDescription = row.getCell(5); Cell stepNo = row.getCell(6); Cell stepDescription = row.getCell(7); Cell expectedResults = row.getCell(8); Cell product = row.getCell(9); Cell dataPlanejada = row.getCell(10); if (listTestCase.size() > 0) { descriptionPlan.setCellValue(listTestCase.get(0).getTestPlan()); prj.setCellValue(listTestCase.get(0).getSTIPRJ()); fase.setCellValue(listTestCase.get(0).getFASE()); testPhase.setCellValue(listTestCase.get(0).getTestPhase()); } for (int i = 0; i < listTestCase.size(); i++) { // estilo.setDataFormat(format.getFormat(formatData)); // estilo.setFillBackgroundColor(HSSFColor.GREEN.index); row = sheetTS.getRow(linha); prj = row.getCell(1); fase = row.getCell(2); testPhase = row.getCell(3); testScriptName = row.getCell(4); testScriptDescription = row.getCell(5); stepNo = row.getCell(6); stepDescription = row.getCell(7); expectedResults = row.getCell(8); product = row.getCell(9); dataPlanejada = row.getCell(10); testScriptName.setCellValue(listTestCase.get(i).getTestScriptName()); testScriptDescription.setCellValue(listTestCase.get(i).getTestScriptDescription()); stepNo.setCellValue(listTestCase.get(i).getSTEP_NUMERO()); stepDescription.setCellValue(listTestCase.get(i).getStepDescription()); expectedResults.setCellValue(listTestCase.get(i).getExpectedResults()); product.setCellValue(listTestCase.get(i).getProduct()); estilo = (XSSFCellStyle) dataPlanejada.getCellStyle(); dataPlanejada.setCellValue(listTestCase.get(i).getDataPlanejada()); dataPlanejada.setCellStyle(estilo); linha = linha + 2; } FileOutputStream fileOut = new FileOutputStream(destinationSheet); workbook.write(fileOut); fileOut.close(); fileSheet.close(); sucess = true; return sucess; }
From source file:com.accenture.ts.dao.TesteCaseTSDAO.java
public boolean newTsSheet(String pathSheet, String nameSheet, TesteCaseTSBean testCase) throws FileNotFoundException, IOException { boolean sucess = false; destinationSheet = new File(pathSheet); destinationSheet.mkdirs();//from ww w .j a v a2 s .c o m destinationSheet = new File(pathSheet + "\\" + nameSheet + ".xlsx"); sourceStheet = new File(sheetDefault); copySheet(sourceStheet, destinationSheet); FileInputStream fileSheet = new FileInputStream(destinationSheet); XSSFWorkbook workbook = new XSSFWorkbook(fileSheet); XSSFSheet sheetTS = workbook.getSheetAt(0); XSSFDataFormat format = workbook.createDataFormat(); XSSFCellStyle estilo = workbook.createCellStyle(); // String formatData = "aaaa-mm-dd\"T12:00:00-03:00\""; int linha = 1; Row row = sheetTS.getRow(linha); Cell descriptionPlan = row.getCell(0); Cell prj = row.getCell(1); Cell fase = row.getCell(2); Cell testPhase = row.getCell(3); Cell testScriptName = row.getCell(4); Cell testScriptDescription = row.getCell(5); Cell stepNo = row.getCell(6); Cell stepDescription = row.getCell(7); Cell expectedResults = row.getCell(8); Cell product = row.getCell(9); Cell dataPlanejada = row.getCell(10); Cell complexidade = row.getCell(11); Cell automatizado = row.getCell(12); descriptionPlan.setCellValue(testCase.getTestPlan()); prj.setCellValue(testCase.getSTIPRJ()); fase.setCellValue(testCase.getFASE()); testPhase.setCellValue(testCase.getTestPhase()); // estilo.setDataFormat(format.getFormat(formatData)); // estilo.setFillBackgroundColor(HSSFColor.GREEN.index); row = sheetTS.getRow(linha); prj = row.getCell(1); fase = row.getCell(2); testPhase = row.getCell(3); testScriptName = row.getCell(4); testScriptDescription = row.getCell(5); stepNo = row.getCell(6); stepDescription = row.getCell(7); expectedResults = row.getCell(8); product = row.getCell(9); dataPlanejada = row.getCell(10); complexidade = row.getCell(11); automatizado = row.getCell(12); testScriptName.setCellValue(testCase.getTestScriptName()); testScriptDescription.setCellValue(testCase.getTestScriptDescription()); stepNo.setCellValue(testCase.getSTEP_NUMERO()); stepDescription.setCellValue(testCase.getStepDescription()); expectedResults.setCellValue(testCase.getExpectedResults()); product.setCellValue(testCase.getProduct()); estilo = (XSSFCellStyle) dataPlanejada.getCellStyle(); dataPlanejada.setCellValue(FunctiosDates.getDateActual()); dataPlanejada.setCellStyle(estilo); complexidade.setCellValue(testCase.getComplexidade()); automatizado.setCellValue(testCase.isAutomatizado()); linha = linha + 2; FileOutputStream fileOut = new FileOutputStream(destinationSheet); workbook.write(fileOut); fileOut.close(); fileSheet.close(); sucess = true; return sucess; }
From source file:com.accenture.ts.dao.TesteCaseTSDAO.java
public boolean createSpreadsheetTS(String pathSheet, String nameSheet, TestPlanTSBean testPlan) throws Exception { boolean sucess = false; destinationSheet = new File(pathSheet); destinationSheet.mkdirs();//from w w w. j a v a2 s . c o m String sheetTI = pathSheet + "\\" + nameSheet; nameSheet = nameSheet.replace("xlsx", "xlsm"); ; destinationSheet = new File(pathSheet + "\\" + nameSheet); sourceStheet = new File("C:\\FastPlan\\sheets\\TS_NEW.xlsm"); logger.info("Realizando cpia da planilha"); boolean existInList = false; List<TesteCaseTSBean> testCasesAutomatizados = new ArrayList<TesteCaseTSBean>(); //run macro String cmd = "C:\\FastPlan\\runMacro.vbs"; Runtime.getRuntime().exec("cmd /c" + cmd); Thread.sleep(2000); copySheet(sourceStheet, destinationSheet); logger.info("Planilha copiada"); FileInputStream fileSheet = new FileInputStream(destinationSheet); XSSFWorkbook workbook = new XSSFWorkbook(fileSheet); XSSFSheet sheetTS = workbook.getSheetAt(0); XSSFCellStyle estilo = workbook.createCellStyle(); // workbook.setSheetName(workbook.getSheetIndex(sheetTS), FunctiosDates.dateToString(FunctiosDates.getDateActual(), "yyyy-MM-dd-HH-mm-ss")); int linha = 2; Row row = sheetTS.getRow(linha); Cell descriptionPlan = row.getCell(0); Cell release = row.getCell(1); Cell prj = row.getCell(2); Cell fase = row.getCell(3); Cell testPhase = row.getCell(4); Cell testScriptName = row.getCell(5); Cell testScriptDescription = row.getCell(6); Cell stepNo = row.getCell(7); Cell stepDescription = row.getCell(8); Cell expectedResults = row.getCell(9); Cell product = row.getCell(10); Cell dataPlanejada = row.getCell(11); Cell qtdSteps = row.getCell(12); Cell complexidade = row.getCell(13); Cell automatizado = row.getCell(14); logger.info("Inserindo dados do plano"); descriptionPlan.setCellValue(testPlan.getName()); release.setCellValue(testPlan.getRelease()); for (int i = 0; i < testPlan.getTestCase().size(); i++) { row = sheetTS.getRow(linha); descriptionPlan = row.getCell(0); release = row.getCell(1); prj = row.getCell(2); fase = row.getCell(3); testPhase = row.getCell(4); testScriptName = row.getCell(5); testScriptDescription = row.getCell(6); stepNo = row.getCell(7); stepDescription = row.getCell(8); expectedResults = row.getCell(9); product = row.getCell(10); dataPlanejada = row.getCell(11); qtdSteps = row.getCell(12); complexidade = row.getCell(13); automatizado = row.getCell(14); logger.info("Inserindo dados dos TCs"); System.out.println("com.accenture.ts.dao.TesteCaseTSDAO.createSpreadsheetTS() - " + testPlan.getSti() + " - " + "row:" + linha); prj.setCellValue(testPlan.getSti()); fase.setCellValue(testPlan.getCrFase()); testPhase.setCellValue(testPlan.getTestPhase()); testScriptName.setCellValue(testPlan.getTestCase().get(i).getTestScriptName()); testScriptDescription.setCellValue(testPlan.getTestCase().get(i).getTestScriptDescription()); product.setCellValue(testPlan.getTestCase().get(i).getProduct()); estilo = (XSSFCellStyle) dataPlanejada.getCellStyle(); dataPlanejada.setCellValue(testPlan.getTestCase().get(i).getDataPlanejada()); dataPlanejada.setCellStyle(estilo); qtdSteps.setCellValue(testPlan.getTestCase().get(i).getListStep().size()); complexidade.setCellValue(testPlan.getTestCase().get(i).getComplexidade()); //set colors if (i % 2 == 0) { System.out.println("com.accenture.ts.dao.TesteCaseTSDAO.createSpreadsheetTS() - entrou"); // setColorCells(new Cell[]{descriptionPlan, release, prj, fase, testPhase, testScriptName, testScriptDescription, stepNo, // stepDescription, expectedResults, product, dataPlanejada, qtdSteps, complexidade}, workbook); XSSFCellStyle styleColor = (XSSFCellStyle) product.getCellStyle(); styleColor.setFillBackgroundColor(HSSFColor.LIGHT_GREEN.index); product.setCellStyle(styleColor); } for (int j = 0; j < testPlan.getTestCase().get(i).getListStep().size(); j++) { row = sheetTS.getRow(linha); stepNo = row.getCell(7); stepDescription = row.getCell(8); expectedResults = row.getCell(9); // // stepNo.setCellValue(testPlan.getTestCase().get(i).getListStep().get(j).getNomeStep()); logger.info("Inserindo dados dos Steps"); stepNo.setCellValue(j + 1); stepDescription.setCellValue(testPlan.getTestCase().get(i).getListStep().get(j).getDescStep()); expectedResults.setCellValue(testPlan.getTestCase().get(i).getListStep().get(j).getResultadoStep()); linha = linha + 1; row = sheetTS.getRow(linha); stepNo = row.getCell(7); stepDescription = row.getCell(8); expectedResults = row.getCell(9); } linha = linha + 1; row = sheetTS.getRow(linha); descriptionPlan = row.getCell(0); release = row.getCell(1); prj = row.getCell(2); fase = row.getCell(3); testPhase = row.getCell(4); testScriptName = row.getCell(5); testScriptDescription = row.getCell(6); stepNo = row.getCell(7); stepDescription = row.getCell(8); expectedResults = row.getCell(9); product = row.getCell(10); dataPlanejada = row.getCell(11); qtdSteps = row.getCell(12); complexidade = row.getCell(13); automatizado = row.getCell(14); logger.info("Dados inseridos na planilha"); if (testPlan.getTestCase().get(i).isAutomatizado()) { for (int j = 0; j < testCasesAutomatizados.size(); j++) { if (testPlan.getTestCase().get(i).equals(testCasesAutomatizados.get(j).getTestScriptName())) { existInList = true; } } if (!existInList) { testCasesAutomatizados.add(testPlan.getTestCase().get(i)); existInList = true; } } } ExtraiPlanilha extraiPlanilha = new ExtraiPlanilha(); extraiPlanilha.exportTStoTI(testCasesAutomatizados, sheetTI); logger.info("Preparando para salvar planilha"); FileOutputStream fileOut = new FileOutputStream(destinationSheet); logger.info("Fim mtodo - new FileOutputStream(destinationSheet) "); logger.info("Tentando gravar na planilha."); workbook.write(fileOut); logger.info("Fim mtodo - workbook.write(fileOut)"); fileOut.close(); fileSheet.close(); sucess = true; logger.info("Planilha gerada."); return sucess; }
From source file:com.accenture.ts.dao.TesteCaseTSDAO.java
public boolean newTsSheet(String pathSheet, String nameSheet, TestPlanTSBean testPlan) throws Exception { boolean sucess = false; destinationSheet = new File(pathSheet); destinationSheet.mkdirs();//from w w w . ja v a 2 s. c om destinationSheet = new File(pathSheet + "\\" + nameSheet); sourceStheet = new File(sheetDefault); copySheet(sourceStheet, destinationSheet); FileInputStream fileSheet = new FileInputStream(destinationSheet); XSSFWorkbook workbook = new XSSFWorkbook(fileSheet); XSSFSheet sheetTS = workbook.getSheetAt(0); XSSFDataFormat format = workbook.createDataFormat(); XSSFCellStyle estilo = workbook.createCellStyle(); // String formatData = "aaaa-mm-dd\"T12:00:00-03:00\""; int linha = 1; Row row = sheetTS.getRow(linha); Cell descriptionPlan = row.getCell(0); Cell prj = row.getCell(1); Cell fase = row.getCell(2); Cell testPhase = row.getCell(3); Cell testScriptName = row.getCell(4); Cell testScriptDescription = row.getCell(5); Cell stepNo = row.getCell(6); Cell stepDescription = row.getCell(7); Cell expectedResults = row.getCell(8); Cell product = row.getCell(9); Cell dataPlanejada = row.getCell(10); Cell complexidade = row.getCell(11); descriptionPlan.setCellValue(testPlan.getName()); prj.setCellValue(testPlan.getSti()); fase.setCellValue(testPlan.getCrFase()); testPhase.setCellValue(testPlan.getTestPhase()); // estilo.setDataFormat(format.getFormat(formatData)); // estilo.setFillBackgroundColor(HSSFColor.GREEN.index); for (int i = 0; i < testPlan.getTestCase().size(); i++) { row = sheetTS.getRow(linha); prj = row.getCell(1); fase = row.getCell(2); testPhase = row.getCell(3); testScriptName = row.getCell(4); testScriptDescription = row.getCell(5); stepNo = row.getCell(6); stepDescription = row.getCell(7); expectedResults = row.getCell(8); product = row.getCell(9); dataPlanejada = row.getCell(10); complexidade = row.getCell(11); testScriptName.setCellValue(testPlan.getTestCase().get(i).getTestScriptName()); testScriptDescription.setCellValue(testPlan.getTestCase().get(i).getTestScriptDescription()); stepNo.setCellValue(testPlan.getTestCase().get(i).getSTEP_NUMERO()); stepDescription.setCellValue(testPlan.getTestCase().get(i).getStepDescription()); expectedResults.setCellValue(testPlan.getTestCase().get(i).getExpectedResults()); product.setCellValue(testPlan.getTestCase().get(i).getProduct()); estilo = (XSSFCellStyle) dataPlanejada.getCellStyle(); dataPlanejada.setCellValue(testPlan.getTestCase().get(i).getDataPlanejada()); dataPlanejada.setCellStyle(estilo); complexidade.setCellValue(testPlan.getTestCase().get(i).getComplexidade()); linha = linha + 2; row = sheetTS.getRow(linha); prj = row.getCell(1); fase = row.getCell(2); testPhase = row.getCell(3); testScriptName = row.getCell(4); testScriptDescription = row.getCell(5); stepNo = row.getCell(6); stepDescription = row.getCell(7); expectedResults = row.getCell(8); product = row.getCell(9); dataPlanejada = row.getCell(10); complexidade = row.getCell(11); } FileOutputStream fileOut = new FileOutputStream(destinationSheet); workbook.write(fileOut); fileOut.close(); fileSheet.close(); sucess = true; return sucess; }
From source file:com.accenture.ts.dao.TesteCaseTSDAO.java
public boolean updateTsSheet(String pathSheet, String nameSheet, TesteCaseTSBean testCase) throws FileNotFoundException, IOException { boolean sucess = false; destinationSheet = new File(pathSheet); destinationSheet.mkdirs();//from w ww . j a v a2 s . c o m destinationSheet = new File(pathSheet + "\\" + nameSheet); sourceStheet = new File(sheetDefault); copySheet(sourceStheet, destinationSheet); FileInputStream fileSheet = new FileInputStream(destinationSheet); XSSFWorkbook workbook = new XSSFWorkbook(fileSheet); XSSFSheet sheetTS = workbook.getSheetAt(0); XSSFDataFormat format = workbook.createDataFormat(); XSSFCellStyle estilo = workbook.createCellStyle(); // String formatData = "aaaa-mm-dd\"T12:00:00-03:00\""; int linha = 1; Row row = sheetTS.getRow(linha); Cell descriptionPlan = row.getCell(0); Cell prj = row.getCell(1); Cell fase = row.getCell(2); Cell testPhase = row.getCell(3); Cell testScriptName = row.getCell(4); Cell testScriptDescription = row.getCell(5); Cell stepNo = row.getCell(6); Cell stepDescription = row.getCell(7); Cell expectedResults = row.getCell(8); Cell product = row.getCell(9); Cell dataPlanejada = row.getCell(10); Cell complexidade = row.getCell(11); Cell automatizado = row.getCell(12); descriptionPlan.setCellValue(testCase.getTestPlan()); prj.setCellValue(testCase.getSTIPRJ()); fase.setCellValue(testCase.getFASE()); testPhase.setCellValue(testCase.getTestPhase()); // estilo.setDataFormat(format.getFormat(formatData)); // estilo.setFillBackgroundColor(HSSFColor.GREEN.index); row = sheetTS.getRow(linha); prj = row.getCell(1); fase = row.getCell(2); testPhase = row.getCell(3); testScriptName = row.getCell(4); testScriptDescription = row.getCell(5); stepNo = row.getCell(6); stepDescription = row.getCell(7); expectedResults = row.getCell(8); product = row.getCell(9); dataPlanejada = row.getCell(10); complexidade = row.getCell(11); automatizado = row.getCell(12); testScriptName.setCellValue(testCase.getTestScriptName()); testScriptDescription.setCellValue(testCase.getTestScriptDescription()); stepNo.setCellValue(testCase.getSTEP_NUMERO()); stepDescription.setCellValue(testCase.getStepDescription()); expectedResults.setCellValue(testCase.getExpectedResults()); product.setCellValue(testCase.getProduct()); estilo = (XSSFCellStyle) dataPlanejada.getCellStyle(); dataPlanejada.setCellValue(testCase.getDataPlanejada()); dataPlanejada.setCellStyle(estilo); complexidade.setCellValue(testCase.getComplexidade()); automatizado.setCellValue(testCase.isAutomatizado()); linha = linha + 2; FileOutputStream fileOut = new FileOutputStream(destinationSheet); workbook.write(fileOut); fileOut.close(); fileSheet.close(); sucess = true; return sucess; }
From source file:com.anritsu.mcrepositorymanager.utils.GenerateRSS.java
public String getRSS() { FileInputStream file = null;/* w w w .ja va 2 s.c o m*/ String rssFileName = rssTemplateFileName.replaceAll("template", mcVersion); try { file = new FileInputStream( new File(Configuration.getInstance().getRssTemplatePath() + rssTemplateFileName)); XSSFWorkbook workbook = new XSSFWorkbook(file); workbook.setSheetName(workbook.getSheetIndex("MC X.X.X"), "MC " + mcVersion); XSSFSheet sheet = workbook.getSheet("MC " + mcVersion); CreationHelper createHelper = workbook.getCreationHelper(); Cell cell = null; // Update the sheet title cell = sheet.getRow(0).getCell(0); cell.setCellValue(cell.getStringCellValue().replaceAll("template", mcVersion)); XSSFCellStyle cellStyle = workbook.createCellStyle(); cellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); cellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN); cellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN); cellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN); XSSFCellStyle hlinkstyle = workbook.createCellStyle(); XSSFFont hlinkfont = workbook.createFont(); hlinkfont.setUnderline(XSSFFont.U_SINGLE); hlinkfont.setColor(HSSFColor.BLUE.index); hlinkstyle.setFont(hlinkfont); hlinkstyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); hlinkstyle.setBorderTop(XSSFCellStyle.BORDER_THIN); hlinkstyle.setBorderRight(XSSFCellStyle.BORDER_THIN); hlinkstyle.setBorderLeft(XSSFCellStyle.BORDER_THIN); XSSFCellStyle dateCellStyle = workbook.createCellStyle(); dateCellStyle.setDataFormat(createHelper.createDataFormat().getFormat("dd-MMMM-yyyy")); dateCellStyle.setBorderBottom(XSSFCellStyle.BORDER_THIN); dateCellStyle.setBorderTop(XSSFCellStyle.BORDER_THIN); dateCellStyle.setBorderRight(XSSFCellStyle.BORDER_THIN); dateCellStyle.setBorderLeft(XSSFCellStyle.BORDER_THIN); // Populate the table int rowCount = 1; for (RecommendedMcPackage rmcp : sortedMcPackages) { if (rmcp.getRecommendedVersion() != null && rmcp.isShowInTable()) { Row row = sheet.createRow(rowCount + 1); rowCount++; cell = row.createCell(0); cell.setCellValue(rmcp.getTier().replaceAll("Anritsu/MasterClaw/", "")); cell.setCellStyle(cellStyle); cell = row.createCell(1); cell.setCellValue(rmcp.getGroup()); cell.setCellStyle(cellStyle); cell = row.createCell(2); cell.setCellValue(rmcp.getPackageName()); UrlValidator defaultValidator = new UrlValidator(UrlValidator.ALLOW_LOCAL_URLS); if (rmcp.getRecommendedVersion().getReleaseNote() != null && defaultValidator.isValid(rmcp.getRecommendedVersion().getReleaseNote())) { XSSFHyperlink releaseNotelink = (XSSFHyperlink) createHelper .createHyperlink(Hyperlink.LINK_URL); releaseNotelink.setAddress(rmcp.getRecommendedVersion().getReleaseNote()); //System.out.println("Inside(if) RN: " + rmcp.getRecommendedVersion().getReleaseNote() + " Valid: " + defaultValidator.isValid(rmcp.getRecommendedVersion().getReleaseNote())); cell.setHyperlink(releaseNotelink); } cell.setCellStyle(hlinkstyle); cell = row.createCell(3); cell.setCellValue(rmcp.getRecommendedVersion().getPackageVersion()); cell.setCellStyle(cellStyle); cell = row.createCell(4); cell.setCellValue(rmcp.getAvailability()); cell.setCellStyle(cellStyle); cell = row.createCell(5); String customers = Arrays.asList(rmcp.getRecommendedVersion().getCustomerList().toArray()) .toString(); if (customers.equalsIgnoreCase("[All]")) { customers = ""; } cell.setCellValue(customers); cell.setCellStyle(cellStyle); cell = row.createCell(6); cell.setCellValue(rmcp.getRecommendedVersion().getRisk()); cell.setCellStyle(cellStyle); cell = row.createCell(7); cell.setCellValue(rmcp.getPackageName()); XSSFHyperlink link = (XSSFHyperlink) createHelper.createHyperlink(Hyperlink.LINK_URL); link.setAddress(rmcp.getRecommendedVersion().getDownloadLinks().iterator().next()); cell.setHyperlink((XSSFHyperlink) link); cell.setCellStyle(hlinkstyle); cell = row.createCell(8); cell.setCellValue((rmcp.getRecommendedVersion() != null && rmcp.getRecommendedVersion().isLessRecommended()) ? "#" : ""); cell.setCellStyle(cellStyle); cell = row.createCell(9); cell.setCellValue(rmcp.getRecommendedVersion().getNotes()); cell.setCellStyle(cellStyle); StringBuilder newFeatures = new StringBuilder(); for (MCPackageActivities mcpa : rmcp.getRecommendedVersion().getActivities()) { if (!mcpa.getActivityType().equalsIgnoreCase("epr")) { newFeatures.append(mcpa.getActivityType() + " " + mcpa.getActivityId() + "; "); } } cell = row.createCell(10); cell.setCellValue(newFeatures.toString()); cell.setCellStyle(cellStyle); cell = row.createCell(11); cell.setCellValue(rmcp.getRecommendedVersion().getReleaseDate()); cell.setCellStyle(dateCellStyle); } sheet.autoSizeColumn(0); sheet.autoSizeColumn(1); sheet.autoSizeColumn(2); sheet.autoSizeColumn(3); sheet.autoSizeColumn(4); sheet.autoSizeColumn(6); sheet.autoSizeColumn(7); sheet.autoSizeColumn(8); sheet.autoSizeColumn(11); } FileOutputStream outFile = new FileOutputStream( new File(Configuration.getInstance().getRssTemplatePath() + rssFileName)); workbook.write(outFile); outFile.close(); return Configuration.getInstance().getRssTemplatePath() + rssFileName; } catch (FileNotFoundException ex) { Logger.getLogger(GenerateRSS.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(GenerateRSS.class.getName()).log(Level.SEVERE, null, ex); } finally { try { file.close(); } catch (IOException ex) { Logger.getLogger(GenerateRSS.class.getName()).log(Level.SEVERE, null, ex); } } return ""; }
From source file:com.bc.util.XlsxExporter.java
public static void WriteInvoiceToFile(File output, CustomerOrder order, ArrayList<CustomerOrderItem> items) { try {/* w w w.j a v a 2s . c om*/ if (output.exists()) { log.info(output.getName() + " exists. Deleting"); output.delete(); log.info("Deleted " + output.getName()); } log.info("Creating xlsx file..."); FileOutputStream fos = new FileOutputStream(output); XSSFWorkbook workBook = new XSSFWorkbook(); XSSFSheet sheet = workBook.createSheet("Order"); CellStyle style = workBook.createCellStyle(); style.setFillBackgroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); style.setFillPattern(CellStyle.ALIGN_FILL); Font font = workBook.createFont(); font.setColor(IndexedColors.WHITE.getIndex()); style.setFont(font); String[] columnHeaders = { "Invoice", "Salesman", "Customer Name", "Customer Code", "PO", "Ship Date", "Post Date", "ISBN", "ISBN13", "Title", "List Price", "Price", "Quantity", "Shipped", "Discount", "Extended Price" }; log.info("Creating header row & columns"); Row row = sheet.createRow(0); for (int i = 0; i < columnHeaders.length; i++) { Cell cell = row.createCell(i); cell.setCellValue(columnHeaders[i]); cell.setCellStyle(style); sheet.setColumnWidth(i, 4500); } sheet.setColumnWidth(9, 13500); log.info("Writing " + items.size() + " records"); XSSFDataFormat decimalFormat = workBook.createDataFormat(); CellStyle dstyle = workBook.createCellStyle(); dstyle.setDataFormat(decimalFormat.getFormat("0.00")); int i = 1; for (CustomerOrderItem orderItem : items) { Row drow = sheet.createRow(i++); Hibernate.initialize(order.getCustomerOrderItems()); String strValue; Float floatValue; Integer intVal; Cell cInvoice = drow.createCell(0); strValue = order.getInvoiceNumber(); if (strValue == null) strValue = ""; cInvoice.setCellValue(order.getInvoiceNumber()); Cell cSalesman = drow.createCell(1); strValue = order.getSalesman(); if (strValue == null) strValue = ""; cSalesman.setCellValue(strValue); Cell cCustomerName = drow.createCell(2); strValue = order.getCustomer().getCompanyName(); if (strValue == null) strValue = ""; cCustomerName.setCellValue(strValue); Cell cCustomerCode = drow.createCell(3); strValue = order.getCustomerCode(); if (strValue == null) strValue = ""; cCustomerCode.setCellValue(strValue); Cell cPo = drow.createCell(4); strValue = order.getPoNumber(); if (strValue == null) strValue = ""; cPo.setCellValue(strValue); Cell cShipDate = drow.createCell(5); Date d = order.getShipDate(); if (d == null) cShipDate.setCellValue(""); else cShipDate.setCellValue("" + d.getMonth() + "/" + d.getDay() + "/" + (1900 + d.getYear())); Cell cPostDate = drow.createCell(6); d = order.getPostDate(); if (d == null) cPostDate.setCellValue(""); else cPostDate.setCellValue("" + d.getMonth() + "/" + d.getDay() + "/" + (1900 + d.getYear())); Hibernate.initialize(orderItem.getInventoryItem()); InventoryItem item = orderItem.getInventoryItem(); //orderItem.getInventoryItem(); if (item != null) { Cell cIsbn = drow.createCell(7); strValue = item.getIsbn(); if (strValue == null) strValue = ""; cIsbn.setCellValue(strValue); Cell cIsbn13 = drow.createCell(8); strValue = item.getIsbn13(); if (strValue == null) strValue = ""; cIsbn13.setCellValue(strValue); Cell cTitle = drow.createCell(9); strValue = item.getTitle(); if (strValue == null) strValue = ""; cTitle.setCellValue(strValue); Cell cListPrice = drow.createCell(10); floatValue = item.getListPrice(); cListPrice.setCellStyle(dstyle); if (floatValue == null) floatValue = 0.0f; cListPrice.setCellValue(floatValue); Cell cPrice = drow.createCell(11); floatValue = item.getSellingPrice(); cPrice.setCellStyle(dstyle); if (floatValue == null) floatValue = 0.0f; cPrice.setCellValue(floatValue); } Cell cQuantity = drow.createCell(12); intVal = orderItem.getQuantity(); log.info("Quantity : " + intVal); if (intVal == null) intVal = 0; cQuantity.setCellValue(intVal); Cell cShipped = drow.createCell(13); intVal = orderItem.getFilled(); log.info("Shipped QTY : " + intVal); if (intVal == null) intVal = 0; cShipped.setCellValue(intVal); Cell cDiscount = drow.createCell(14); cDiscount.setCellStyle(dstyle); floatValue = orderItem.getDiscount(); if (floatValue == null) floatValue = 0.0f; cDiscount.setCellValue(floatValue); Cell cExtendedPrice = drow.createCell(15); cExtendedPrice.setCellStyle(dstyle); BigDecimal dValue = orderItem.getTotalPrice(); if (dValue == null) dValue = BigDecimal.ZERO; cExtendedPrice.setCellValue(dValue.doubleValue()); } workBook.write(fos); log.info("Finished writing data, closing..."); fos.close(); log.info("Completed exporting data to " + output.getAbsolutePath()); } catch (Exception ex) { Logger.getLogger(XlsxExporter.class.getName()).log(Level.SEVERE, null, ex); } }