HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(
file));
// 获得第一个工作表对象
HSSFSheet sheet = workbook.getSheetAt(0);
// 得到有效的行数
int countRows = sheet.getLastRowNum();
int countColumns = 0;
//第一行为表头,从第二行开始读数据
for (int i = 1; i <= countRows; i++) {
// 获取行对象
HSSFRow row = sheet.getRow(i);
if (row == null)
continue;
// 一行的单元格数量
countColumns = row.getLastCellNum();
for (int j = 0; j < countColumns; j++) {
// 获取单元格
HSSFCell cell = row.getCell(j);
String strCell = "";
if (null != cell) {
switch (cell.getCellType()) {
case HSSFCell.CELL_TYPE_NUMERIC:// 数字类型
.........
break;
}
}
}
}
追问遍历行之后输出行中带有ponumber的后面三列的内容,责骂么、怎么做
追答没懂起神马意思 可以 按次序读列啊 判断当前列是否有ponumber 如果没有就continue,有了就取ponumber的后3列舍
你是不是要把内容转换为xml文档?
利用DOM4J构建一个xml文件
Document doc = DocumentHelper.createDocument();