Example usage for org.apache.poi.ss.usermodel Cell getStringCellValue

List of usage examples for org.apache.poi.ss.usermodel Cell getStringCellValue

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Cell getStringCellValue.

Prototype

String getStringCellValue();

Source Link

Document

Get the value of the cell as a string

For numeric cells we throw an exception.

Usage

From source file:com.accenture.control.ExcelDAO.java

public String[] carregaPlanilhaSistemaMaster() throws IOException {

    Plano plano = new Plano();

    String[] sistemaMaster = null;
    try {//from w w w  .  ja  v a 2 s.c  o  m
        FileInputStream arquivo = new FileInputStream(new File(ExcelDAO.fileName));
        XSSFWorkbook workbook = new XSSFWorkbook(arquivo);
        //setado a planilha de configuraes
        XSSFSheet sheetPlano = workbook.getSheetAt(2);
        //linha pa
        int linha = 1;
        int coluna = 2;

        sistemaMaster = new String[sheetPlano.getLastRowNum()];
        int index = 0;
        for (int count = 1; count < sheetPlano.getLastRowNum(); count++) {
            Row row = sheetPlano.getRow(count);
            for (int countColuna = 0; countColuna < 1; countColuna++) {
                Cell cell = row.getCell(coluna, Row.CREATE_NULL_AS_BLANK);
                System.out.println(cell.getColumnIndex() + "-" + cell.getRowIndex());
                if (cell.getCellType() == CELL_TYPE_BLANK) {
                    System.out.println("Campo vazio");
                } else if (cell.getCellType() == CELL_TYPE_NUMERIC) {
                    double valor = cell.getNumericCellValue();
                    System.out.println(valor);
                } else {
                    String valor = cell.getStringCellValue();
                    System.out.println(valor);
                    sistemaMaster[index] = valor;
                    System.out.println(sistemaMaster[index]);
                    index++;
                }
            }
        }

    } catch (FileNotFoundException ex) {
        Logger.getLogger(ExcelDAO.class.getName()).log(Level.SEVERE, null, ex);
    }
    return sistemaMaster;
}

From source file:com.accenture.control.ExtraiPlanilha.java

public List<CasoTesteTemp> getCTExistentes(String planilha) throws FileNotFoundException, IOException {
    List<CasoTesteTemp> listCT = new ArrayList<CasoTesteTemp>();

    //criando variavel que recebe a planilha  selecionada
    FileInputStream arquivo = new FileInputStream(new File(planilha));
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);
    XSSFSheet sheetPlano = workbook.getSheetAt(1);

    //nmero da linha que deve comear a leitura da clula -- primeira linha = 0
    int linha = 7;
    //criando variavel row que receber o numero da da linha
    Row row = sheetPlano.getRow(linha);/*from  w ww.  j a v a 2 s  .c om*/
    //Criando varialvel do tipo Cell onde recebe a variavel row 
    Cell celCasoTeste = row.getCell(12);
    //variavel para identificar a posicao da lista onde sera inserido o objeto
    int indice = 0;
    int countAdd = 0;

    //loop onde  verificado se a celula do CT est vazia, caso nao sera armazenada
    while (!celCasoTeste.getStringCellValue().equals("")) {
        //instacia um objeto CasoTesteTemp 
        CasoTesteTemp ct = new CasoTesteTemp();
        //atribui valor da celula para o objeto ct 
        ct.setCasoTeste(celCasoTeste.getStringCellValue());
        //numero da celula recebe valor da linha
        int numeroLinhaCel = linha;
        //atribui valor recbe referencia da celula
        ct.setCelula(numeroLinhaCel);
        //lista de CT recebe novo CT
        if (!testCaseAlreadyExists(listCT, ct)) {
            listCT.add(countAdd, ct);
            countAdd++;
        }

        //linha recebe mais 25 para ir para proximo CT da planilha
        linha = 25 + linha;
        //variavel row recebe nova linha
        row = sheetPlano.getRow(linha);
        //variavel cell recebe nova linha
        celCasoTeste = row.getCell(12);

        //incrementa 1 na variavel 
        indice++;

    }

    return listCT;
}

From source file:com.accenture.control.ExtraiPlanilha.java

public String extraiPlanilhaPlanos(String planilha)
        throws SQLException, ClassNotFoundException, FileNotFoundException, IOException {

    String msg;/* w ww.  j av  a2 s  .  co  m*/

    Plano p = new Plano();

    ManipulaDados md = new ManipulaDados();
    ManipulaDadosSQLite bdLite = new ManipulaDadosSQLite();
    //capturando arquivo recebido 
    FileInputStream arquivo = new FileInputStream(new File(planilha));
    System.out.println(planilha);
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);

    XSSFSheet sheetAlunos = workbook.getSheetAt(1);
    int linha = 7;
    int numCelula = 1;

    Row row = sheetAlunos.getRow(linha);
    Cell celCadeia = row.getCell(1);
    Cell celSegmento = row.getCell(2);
    Cell ccelProduto = 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(18);
    Cell celCenarioAuto = row.getCell(20);
    Cell celType = row.getCell(21);
    Cell celTrg = row.getCell(22);
    Cell celSubject = row.getCell(23);
    Cell celCriacao = row.getCell(24);

    Cell celStep = row.getCell(15);

    //                       Plano p = new Plano();
    Step steps = new Step();

    while (!celCasoTeste.getStringCellValue().equals("")) {
        row = sheetAlunos.getRow(linha);
        celCadeia = row.getCell(1);
        celSegmento = row.getCell(2);
        ccelProduto = 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);
        celQtdSistemas = row.getCell(18);
        celCenarioAuto = row.getCell(20);
        celType = row.getCell(21);
        celTrg = row.getCell(22);
        celSubject = row.getCell(23);
        celCriacao = row.getCell(24);

        System.out.println("Caso de Teste: " + celCasoTeste.getStringCellValue());

        msg = "Extraindo caso de teste: " + celCasoTeste.getStringCellValue();
        //                           form.setAreaTextExtracao(msg);

        p.setCadeia(celCadeia.getStringCellValue());
        p.setSegmento(celSegmento.getStringCellValue());
        p.setProduto(ccelProduto.getStringCellValue());
        p.setFuncionalidade(celFuncionalidade.getStringCellValue());
        p.setCenarioIntegrado(celCenarioIntegracao.getStringCellValue());
        p.setSistemaMaster(celSistemaMaster.getStringCellValue());
        p.setSistemasEnvolvidos(celSistemaEnvolvidos.getStringCellValue());
        p.setFornecedor(celFornecedor.getStringCellValue());
        p.setTpRequisito(celTpRequisito.getStringCellValue());
        p.setRequisito(celRequisito.getStringCellValue());
        p.setCenarioTeste(celCenario.getStringCellValue());
        p.setCasoTeste(celCasoTeste.getStringCellValue());
        p.setDescCasoTeste(celDescricao.getStringCellValue());
        p.setQtdSistemas((int) celQtdSistemas.getNumericCellValue());
        p.setCenarioAutomatizavel(celCenarioAuto.getStringCellValue());
        p.setType(celType.getStringCellValue());
        p.setTrg(celTrg.getStringCellValue());
        p.setSubject(celSubject.getStringCellValue());
        p.setCriacaoAlteracao(celCriacao.getStringCellValue());

        bdLite.insertPlano(p);
        celStep = row.getCell(15);
        int linhaStep = linha;
        linha = 25 + linha;
        row = sheetAlunos.getRow(linha);
        celCasoTeste = row.getCell(12);

        while (!celStep.getStringCellValue().equals("")) {

            row = sheetAlunos.getRow(linhaStep);
            Cell celNomeStep = row.getCell(15);
            Cell celDescStep = row.getCell(16);
            Cell celResultadoStep = row.getCell(17);

            //                              steps.setIdPlano(md.getIdPlanoBanco(p));
            steps.setIdPlano(bdLite.getIdPlanoBanco(p));
            steps.setNomeStep(celNomeStep.getStringCellValue());
            steps.setDescStep(celDescStep.getStringCellValue());
            steps.setResultadoStep(celResultadoStep.getStringCellValue());
            p.setStep(steps);
            //                              bd.insertStep(steps.getNomeStep(), steps.getDescStep(), steps.getResultadoStep(), steps.getIdPlano());

            //                              md.insertStep(steps);
            bdLite.insertStep(p);
            linhaStep = linhaStep + 1;

            row = sheetAlunos.getRow(linhaStep);
            celStep = row.getCell(15);
        }
    }

    arquivo.close();

    msg = "Concludo";
    //          form.setAreaTextExtracao(msg);
    return msg;
}

From source file:com.accenture.control.ExtraiPlanilha.java

public String importaCTNovosPlanilha(String planilha, int linha)
        throws SQLException, ClassNotFoundException, FileNotFoundException, IOException {

    String msg;/*from w w w  . j  av  a 2s.  co  m*/

    Plano p = new Plano();

    ManipulaDados md = new ManipulaDados();
    ManipulaDadosSQLite bdLite = new ManipulaDadosSQLite();
    //capturando arquivo recebido 
    FileInputStream arquivo = new FileInputStream(new File(planilha));
    System.out.println(planilha);
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);

    XSSFSheet sheetCTs = workbook.getSheetAt(1);
    //        int linha = 7;

    Row row = sheetCTs.getRow(linha);
    Cell celCadeia = row.getCell(1);
    Cell celSegmento = row.getCell(2);
    Cell ccelProduto = 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);

    //                       Plano p = new Plano();
    Step steps = new Step();

    row = sheetCTs.getRow(linha);
    celCadeia = row.getCell(1);
    celSegmento = row.getCell(2);
    ccelProduto = 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);
    celQtdSistemas = row.getCell(19);
    celCenarioAuto = row.getCell(21);
    celType = row.getCell(22);
    celTrg = row.getCell(23);
    celSubject = row.getCell(24);
    celCriacao = row.getCell(25);

    System.out.println("Caso de Teste: " + celCasoTeste.getStringCellValue());

    msg = "Extraindo caso de teste: " + celCasoTeste.getStringCellValue();
    //                           form.setAreaTextExtracao(msg);

    p.setCadeia(celCadeia.getStringCellValue());
    p.setSegmento(celSegmento.getStringCellValue());
    p.setProduto(ccelProduto.getStringCellValue());
    p.setFuncionalidade(celFuncionalidade.getStringCellValue());
    p.setCenarioIntegrado(celCenarioIntegracao.getStringCellValue());
    p.setSistemaMaster(celSistemaMaster.getStringCellValue());
    p.setSistemasEnvolvidos(celSistemaEnvolvidos.getStringCellValue());
    p.setFornecedor(celFornecedor.getStringCellValue());
    p.setTpRequisito(celTpRequisito.getStringCellValue());
    p.setRequisito(celRequisito.getStringCellValue());
    p.setCenarioTeste(celCenario.getStringCellValue());
    p.setCasoTeste(celCasoTeste.getStringCellValue());
    p.setDescCasoTeste(celDescricao.getStringCellValue());
    p.setQtdSistemas((int) celQtdSistemas.getNumericCellValue());
    p.setCenarioAutomatizavel(celCenarioAuto.getStringCellValue());
    p.setType(celType.getStringCellValue());
    p.setTrg(celTrg.getStringCellValue());
    p.setSubject(celSubject.getStringCellValue());
    p.setCriacaoAlteracao(celCriacao.getStringCellValue());

    bdLite.insertPlano(p);
    celStep = row.getCell(16);
    int linhaStep = linha;
    linha = 25 + linha;
    row = sheetCTs.getRow(linha);
    celCasoTeste = row.getCell(12);

    while (!celStep.getStringCellValue().equals("")) {

        row = sheetCTs.getRow(linhaStep);
        Cell celNomeStep = row.getCell(16);
        Cell celDescStep = row.getCell(17);
        Cell celResultadoStep = row.getCell(18);

        //                              steps.setIdPlano(md.getIdPlanoBanco(p));
        steps.setIdPlano(bdLite.getIdPlanoBanco(p));
        steps.setNomeStep(celNomeStep.getStringCellValue());
        steps.setDescStep(celDescStep.getStringCellValue());
        steps.setResultadoStep(celResultadoStep.getStringCellValue());
        p.setStep(steps);
        //                              bd.insertStep(steps.getNomeStep(), steps.getDescStep(), steps.getResultadoStep(), steps.getIdPlano());

        //                              md.insertStep(steps);
        bdLite.insertStep(p);
        linhaStep = linhaStep + 1;

        row = sheetCTs.getRow(linhaStep);
        celStep = row.getCell(16);
    }

    arquivo.close();

    msg = "Concludo";
    //          form.setAreaTextExtracao(msg);
    return msg;
}

From source file:com.accenture.control.ExtraiPlanilha.java

public String importaCTExistentePlanilha(String planilha, int linha, String nomeCT)
        throws SQLException, ClassNotFoundException, FileNotFoundException, IOException {

    String msg;/*from ww w  . j a  v  a  2s  . c om*/

    Plano p = new Plano();

    ManipulaDadosSQLite bdLite = new ManipulaDadosSQLite();
    //capturando arquivo recebido 
    FileInputStream arquivo = new FileInputStream(new File(planilha));
    System.out.println(planilha);
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);

    XSSFSheet sheetCTs = workbook.getSheetAt(1);
    //        int linha = 7;

    Row row = sheetCTs.getRow(linha);
    Cell celCadeia = row.getCell(1);
    Cell celSegmento = row.getCell(2);
    Cell ccelProduto = 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);

    //                       Plano p = new Plano();
    Step steps = new Step();

    row = sheetCTs.getRow(linha);
    celCadeia = row.getCell(1);
    celSegmento = row.getCell(2);
    ccelProduto = 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);
    celQtdSistemas = row.getCell(19);
    celCenarioAuto = row.getCell(21);
    celType = row.getCell(22);
    celTrg = row.getCell(23);
    celSubject = row.getCell(24);
    celCriacao = row.getCell(25);

    System.out.println("Caso de Teste: " + celCasoTeste.getStringCellValue());
    p.setCasoTeste(nomeCT);
    p = bdLite.getPorCasoTeste(p);

    p.setCadeia(celCadeia.getStringCellValue());
    p.setSegmento(celSegmento.getStringCellValue());
    p.setProduto(ccelProduto.getStringCellValue());
    p.setFuncionalidade(celFuncionalidade.getStringCellValue());
    p.setCenarioIntegrado(celCenarioIntegracao.getStringCellValue());
    p.setSistemaMaster(celSistemaMaster.getStringCellValue());
    p.setSistemasEnvolvidos(celSistemaEnvolvidos.getStringCellValue());
    p.setFornecedor(celFornecedor.getStringCellValue());
    p.setTpRequisito(celTpRequisito.getStringCellValue());
    p.setRequisito(celRequisito.getStringCellValue());
    p.setCenarioTeste(celCenario.getStringCellValue());
    p.setCasoTeste(celCasoTeste.getStringCellValue());
    p.setDescCasoTeste(celDescricao.getStringCellValue());
    p.setQtdSistemas((int) celQtdSistemas.getNumericCellValue());
    p.setCenarioAutomatizavel(celCenarioAuto.getStringCellValue());
    p.setType(celType.getStringCellValue());
    p.setTrg(celTrg.getStringCellValue());
    p.setSubject(celSubject.getStringCellValue());
    p.setCriacaoAlteracao(celCriacao.getStringCellValue());

    bdLite.updatePlano(p);
    celStep = row.getCell(16);
    int linhaStep = linha;
    linha = 25 + linha;
    row = sheetCTs.getRow(linha);
    celCasoTeste = row.getCell(12);

    System.out.println("ID" + p.getId());
    bdLite.deleteStep(p);

    while (!celStep.getStringCellValue().equals("")) {

        row = sheetCTs.getRow(linhaStep);
        Cell celNomeStep = row.getCell(16);
        Cell celDescStep = row.getCell(17);
        Cell celResultadoStep = row.getCell(18);

        //                              steps.setIdPlano(md.getIdPlanoBanco(p));
        steps.setIdPlano(bdLite.getIdPlanoBanco(p));
        steps.setNomeStep(celNomeStep.getStringCellValue());
        steps.setDescStep(celDescStep.getStringCellValue());
        steps.setResultadoStep(celResultadoStep.getStringCellValue());
        p.setStep(steps);
        //                              bd.insertStep(steps.getNomeStep(), steps.getDescStep(), steps.getResultadoStep(), steps.getIdPlano());

        //                              md.insertStep(steps);
        bdLite.insertStep(p);
        linhaStep = linhaStep + 1;

        row = sheetCTs.getRow(linhaStep);
        celStep = row.getCell(16);
    }

    arquivo.close();

    msg = "Concludo";
    //          form.setAreaTextExtracao(msg);
    return msg;
}

From source file:com.accenture.control.ExtraiPlanilha.java

public List<CasoTesteTemp> verificaCTsPlanilha(String planilha)
        throws SQLException, ClassNotFoundException, FileNotFoundException, IOException {

    List<CasoTesteTemp> listPlano = new ArrayList<CasoTesteTemp>();

    ManipulaDados md = new ManipulaDados();
    ManipulaDadosSQLite bdLite = new ManipulaDadosSQLite();
    //capturando arquivo recebido 
    FileInputStream arquivo = new FileInputStream(new File(planilha));
    System.out.println(planilha);
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);

    XSSFSheet sheetAlunos = workbook.getSheetAt(1);
    int linha = 7;
    int numCelula = 1;

    Row row = sheetAlunos.getRow(linha);

    Cell celCasoTeste = row.getCell(12);

    while (!celCasoTeste.getStringCellValue().equals("")) {
        Plano p = new Plano();
        row = sheetAlunos.getRow(linha);

        celCasoTeste = row.getCell(12);//from w  ww  .j  a  va2s  . com

        System.out.println("Caso de Teste: " + celCasoTeste.getStringCellValue());

        celCasoTeste = row.getCell(12);

    }

    arquivo.close();

    return listPlano;
}

From source file:com.accenture.control.ExtraiPlanilha.java

public void extraiConfPlanilha(String diretorio) throws IOException, ClassNotFoundException, SQLException {

    boolean existedados = false;
    ManipulaDadosSQLite bdLite = new ManipulaDadosSQLite();
    FileInputStream arquivo;/*from   ww w.  jav a 2  s .c  o  m*/

    arquivo = new FileInputStream(new File(diretorio));

    System.out.println(diretorio);
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);

    XSSFSheet sheetConf = workbook.getSheetAt(2);
    int linha = 7;
    int numCelula = 1;

    //Capturando dados da Complexidade na celula A1
    int i = 1;
    CellReference cellReference = new CellReference("A" + i);
    Row row = sheetConf.getRow(cellReference.getRow());
    Cell cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    bdLite.deletaTabelaConf("TB_COMPLEXIDADE");

    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_COMPLEXIDADE", "DESC_COMPLEXIDADE", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    bdLite.deletaTabelaConf("TB_AUTOMATIZAVEL");
    //Capturando dados Automatizvel na celula A7
    i = 7;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_AUTOMATIZAVEL");

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_AUTOMATIZAVEL", "DESC_AUTOMATIZAVEL", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados type
    i = 12;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_TYPE");

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_TYPE", "DESC_TYPE", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados TRG
    i = 17;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_TRG");

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_TRG", "DESC_TRG", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados CADEIA
    i = 17;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_CADEIA");

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_CADEIA", "DESC_CADEIA", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados TP REQUISITO
    i = 32;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_TP_REQUISITO");

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_TP_REQUISITO", "DESC_TP_REQUISITO", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados criao/alterao
    i = 27;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_CRIACAO");

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_CRIACAO", "DESC_CRIACAO", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados SISTEMA MASTER
    i = 1;
    cellReference = new CellReference("C" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_SISTEMA_MASTER");

    i++;
    while (cell != null) {
        cellReference = new CellReference("C" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_SISTEMA_MASTER", "DESC_SISTEMA_MASTER", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("C" + i);
        row = sheetConf.getRow(cellReference.getRow());
        if (row == null) {
            cell = null;
        } else {
            cell = row.getCell(cellReference.getCol(), row.RETURN_BLANK_AS_NULL);
        }

    }

    //Capturando dados FUNCIONALIDADE
    i = 1;
    cellReference = new CellReference("E" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_FUNCIONALIDADE");

    i++;
    while (cell != null) {
        cellReference = new CellReference("E" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_FUNCIONALIDADE", "DESC_FUNCIONALIDADE", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("E" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados CENARIO INTEGRADO
    i = 1;
    cellReference = new CellReference("G" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    bdLite.deletaTabelaConf("TB_CENARIO_INTEGRADO");

    i++;
    while (cell != null) {
        cellReference = new CellReference("G" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        existedados = true;
        bdLite.insertTabelaConf("TB_CENARIO_INTEGRADO", "DESC_CENARIO_INTEGRADO", cell.getStringCellValue());
        i++;
        cellReference = new CellReference("G" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    if (existedados == true) {
        bdLite.insertVersaCarga(sheetConf.getSheetName());
    }

}

From source file:com.accenture.control.ImportaDadosConf.java

public int getQtdDadosConf(String diretorio) throws FileNotFoundException, IOException {

    FileInputStream arquivo;/*from ww w  .  j a v  a 2 s .  c o  m*/
    arquivo = new FileInputStream(new File(diretorio));
    //
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);
    //Selecionando a planilha de configuraes
    XSSFSheet sheetConf = workbook.getSheetAt(2);
    int linha = 7;
    int numCelula = 1;
    int i = 1;

    //Caontando COmplexidade
    CellReference cellReference = new CellReference("A" + i);
    Row row = sheetConf.getRow(cellReference.getRow());
    Cell cell = row.getCell(cellReference.getCol());

    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

        qtdConf++;

    }

    i = 7;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

        qtdConf++;

    }

    //Capturando dados type
    i = 12;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        qtdConf++;
    }

    //Capturando dados TRG
    i = 17;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        qtdConf++;
    }

    //Capturando dados CADEIA
    i = 17;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        qtdConf++;
    }

    //Capturando dados TP REQUISITO
    i = 32;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        qtdConf++;
    }

    //Capturando dados criao/alterao
    i = 27;
    cellReference = new CellReference("A" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("A" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        qtdConf++;
    }

    //Capturando dados SISTEMA MASTER
    i = 1;
    cellReference = new CellReference("C" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("C" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("C" + i);
        row = sheetConf.getRow(cellReference.getRow());
        qtdConf++;

        if (row == null) {
            cell = null;

        } else {
            cell = row.getCell(cellReference.getCol(), row.RETURN_BLANK_AS_NULL);
        }

    }

    //Capturando dados FUNCIONALIDADE
    i = 1;
    cellReference = new CellReference("E" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("E" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        qtdConf++;
        i++;
        cellReference = new CellReference("E" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());

    }

    //Capturando dados CENARIO INTEGRADO
    i = 1;
    cellReference = new CellReference("G" + i);
    row = sheetConf.getRow(cellReference.getRow());
    cell = row.getCell(cellReference.getCol());
    System.out.println(cell.getStringCellValue());

    i++;
    while (cell != null) {
        cellReference = new CellReference("G" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        System.out.println(cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());
        texto1.setText("Importando itens de configurao: " + cell.getStringCellValue());
        texto1.paintAll(texto1.getGraphics());

        i++;
        cellReference = new CellReference("G" + i);
        row = sheetConf.getRow(cellReference.getRow());
        cell = row.getCell(cellReference.getCol());
        qtdConf++;
    }

    return qtdConf;
}

From source file:com.accenture.control.ImportaStepPadrao.java

public List<StepPadrao> getStepPadraoPlanilha(String planilha)
        throws SQLException, ClassNotFoundException, FileNotFoundException, IOException {
    int linha = 1;
    List<StepPadrao> listSp = new ArrayList<StepPadrao>();

    // fazendo uma instacia do banco
    ManipulaDadosSQLite bdLite = new ManipulaDadosSQLite();
    //Setando caminho da planilha para o arquivo
    FileInputStream arquivo = new FileInputStream(new File(planilha));
    // Instnciando um workbook e passando o arquivo como parametro
    XSSFWorkbook workbook = new XSSFWorkbook(arquivo);
    //Selecionando a segunda planilha
    XSSFSheet aba = workbook.getSheetAt(1);
    //Selecionando a segunda linha (1)
    Row row = aba.getRow(linha);//from ww  w  .  j ava 2  s .  c o  m
    //selecionando a celula A2
    Cell celVersao = row.getCell(4);

    //Selecionando a segunda linha (1)
    row = aba.getRow(linha);
    //selecionando a celula A2(descrio)
    Cell celDesc = row.getCell(0);
    //selecionando a celula A2(Resultado esperado)
    Cell celResultado = row.getCell(1);
    //selecionando a celula A2(tipo)
    Cell celTipo = row.getCell(2);
    //selecionando a celula A2(sistema)
    Cell celSistema = row.getCell(3);

    //loop para capturar todos os steps padrao da planilha
    while (celDesc != null) {
        StepPadrao sp = new StepPadrao();
        row = aba.getRow(linha);
        celDesc = row.getCell(0);
        celResultado = row.getCell(1);
        celTipo = row.getCell(2);
        celSistema = row.getCell(3);
        celVersao = row.getCell(4);

        sp.setDescStep(celDesc.getStringCellValue());
        sp.setResultadoStep(celResultado.getStringCellValue());
        sp.setTipoStepPadrao(celTipo.getStringCellValue());
        sp.setSistema(celSistema.getStringCellValue());
        sp.setVersao(celVersao.getNumericCellValue());
        linha++;
        listSp.add(sp);
        row = aba.getRow(linha);
        celDesc = row.getCell(0);
        celResultado = row.getCell(1);
        celTipo = row.getCell(2);
        celSistema = row.getCell(3);
        celVersao = row.getCell(4);
    }

    return listSp;
}

From source file:com.accenture.ts.dao.TesteCaseTSDAO.java

public List<TesteCaseTSBean> readSheet(String pathSheetFull) throws FileNotFoundException, IOException {

    List<TesteCaseTSBean> listTS = new ArrayList<TesteCaseTSBean>();

    FileInputStream fileSheet = new FileInputStream(new File(pathSheetFull));
    XSSFWorkbook workbook = new XSSFWorkbook(fileSheet);
    XSSFSheet sheetTS = workbook.getSheetAt(0);

    int linha = 1;

    Row row = sheetTS.getRow(linha);/* w  w  w. j av  a 2  s  . c o m*/

    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);

    String descPlan = null;
    String project = null;
    String phase = null;

    if (!testScriptName.equals("")) {
        descPlan = descriptionPlan.getStringCellValue();
        project = prj.getStringCellValue();
        phase = testPhase.getStringCellValue();
    }

    while (!testScriptName.getStringCellValue().equals("") && testScriptName != null) {

        testCase = new TesteCaseTSBean();

        testCase.setTestScriptName(testScriptName.getStringCellValue());
        testCase.setTestScriptDescription(testScriptDescription.getStringCellValue());
        testCase.setStepDescription(stepDescription.getStringCellValue());
        testCase.setExpectedResults(expectedResults.getStringCellValue());
        testCase.setProduct(product.getStringCellValue());
        //            testCase.setDataPlanejada(dataPlanejada.getDateCellValue());
        testCase.setFase(fase.getStringCellValue());
        testCase.setTestPlan(descPlan);
        testCase.setSTIPRJ(project);
        testCase.setTestPhase(phase);
        testCase.setComplexidade(complexidade.getStringCellValue());
        testCase.setAutomatizado(automatizado.getBooleanCellValue());
        listTS.add(testCase);

        linha = linha + 2;

        row = sheetTS.getRow(linha);
        descriptionPlan = row.getCell(0);
        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);

    }

    return listTS;
}