-1

I have got the following code:

        HSSFSheet sheet = workbook.getSheetAt(0);

        Cell resultCell=(Cell) sheet.getRow(1).getCell(0);

Problem is result cell doesn't have any method setCellValue(). Following statement gives me an error

 resultCell.setCellValue("PASS");
puffles
  • 352
  • 2
  • 5
  • 23
  • [Cell](https://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Cell.html#setCellValue%28double%29) very much has a `setCellValue` method! Whyever would you think it didn't? – Gagravarr May 26 '16 at 17:36
  • @Gagravarr No it doesn't. Check it in an IDE. HSSFCell has a setcellvalue method – puffles May 27 '16 at 04:48
  • I did, and it very much does! You must have imported the wrong class – Gagravarr May 27 '16 at 12:07

2 Answers2

0

If you look at the Apache POI JavaDocs for Cell, or the Apache POI Cell examples on the website, you will clearly see that org.apache.poi.ss.usermodel.Cell has a number of setCellValue methods including setCellValue(double) and setCellValue(String)

Most likely you've imported the wrong class for Cell. You should review the import statements at the top of your class, remove the wrong ones, and ensure you only have one of:

import org.apache.poi.ss.usermodel.Worbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Cell;

or:

import org.apache.poi.ss.usermodel.*;
Gagravarr
  • 47,320
  • 10
  • 111
  • 156
-1

The correct code is this one HSSFCell resultCell= sheet.getRow(1).getCell(0); I were not supposed to caste the cell object

puffles
  • 352
  • 2
  • 5
  • 23