Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

740
Visualizações
CellType cannot be resolved to a variable setCellType error Apache POI - Java

I was reading the Apache poi guide: https://poi.apache.org/spreadsheet/quick-guide.html

And I decided to follow along and type the code into my Eclipse project, and while writing the "Reading and Rewriting Workbooks" section, I got this error in eclipse:

CellType cannot be resolved to a variable

And I was wondering why? I found on another post in Stack Overflow to change this line:

cell.setCellType(CellType.STRING);

to:

cell.setCellType(HSSFCellType.STRING);//or XSSFCell

But it doesn't work, is there anything wrong with my code? (Which btw, I copied and pasted from apache's website)

 InputStream inp = new FileInputStream("workbook.xls");

 Workbook wb = WorkbookFactory.create(inp);
 Sheet sheet = wb.getSheetAt(0);
 Row row = sheet.getRow(2);
 Cell cell = row.getCell(3);
 if (cell == null)
     cell = row.createCell(3);
 cell.setCellType(CellType.STRING);
 cell.setCellValue("a test");

 //Write 
 FileOutputStream fileOut = new FileOutputStream("workbook.xls");
 wb.write(fileOut);
 fileOut.close();
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You must consider the POI version. CellType is only available for new version of POI and the Cell is the old version. My recommendation that you should using POI version 3.15. In this version you would not have to set cell type before set value to it. (It have setStringValue or setDateValue... for you datatype)

over 4 years ago · Santiago Trujillo Relatório

0

Change this cell.setCellType(CellType.STRING); to :

   cell.setCellType(STRING);
over 4 years ago · Santiago Trujillo Relatório

0

Use XSSFCell.CELL_TYPE_STRING or CellType.STRING

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda