On 14 mei, 16:35, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<9334d823-1082-4ef4-bba2-688432ed9...@e20g2000vbc.googlegroups.com>,
dendeezen <tsd35...@scarlet.be> wrote:
[Please trim signatures. See below.]
Eclipse gives the following: (I wrote 'the problem' in capitals)
for (Cell cell : ROW) {
Can only iterate over an array or an instance of java.long.Iterable
if (HSSFDateUtil.ISCELLDATEFORMATTED(cell)) {
The method CellDateFormatted(HSSFCell) in the type HSSFDateUtil is not
applicable for the arguments (Cell)
I am working my way trough the manual :-)
Excellent. You have shown the error, although cut & paste would surely
be easier and more reliable. It would help to see the line numbers and
the full source that you tried. Before you do that, study the example
below; see if you can reproduce the result. [NB: the path separator on
your system may be different.]
<console>
$ javac -cp poi-3.5-beta5-20090219.jar POIExcelReader.java
$ java -cp .:poi-3.5-beta5-20090219.jar POIExcelReader
Tue May 12 00:00:00 EDT 2009
123.0
ABCabc
true
3+3
</console>
<code>
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DateUtil;
public class POIExcelReader {
public static void main(String[] args) throws IOException {
InputStream myxls = new FileInputStream("test.xls");
HSSFWorkbook book = new HSSFWorkbook(myxls);
HSSFSheet sheet = book.getSheetAt(0);
HSSFRow row = sheet.getRow(2);
for (Cell cell : row) {
printCell(cell);
}
}
private static void printCell(Cell cell) {
switch (cell.getCellType()) {
case Cell.CELL_TYPE_BLANK:
System.out.println("EMPTY");
break;
case Cell.CELL_TYPE_STRING:
System.out.println(cell.getStringCellValue());
break;
case Cell.CELL_TYPE_NUMERIC:
if (DateUtil.isCellDateFormatted(cell)) {
System.out.println(cell.getDateCellValue());
} else {
System.out.println(cell.getNumericCellValue());
}
break;
case Cell.CELL_TYPE_BOOLEAN:
System.out.println(cell.getBooleanCellValue());
break;
case Cell.CELL_TYPE_FORMULA:
System.out.println(cell.getCellFormula());
break;
default:
System.out.println("DEFAULT");
}
}}
</code>
--
[This signature intentionally left blank. See above.]
I saw similar things as in your code.