日期:2014-05-17 浏览次数:20774 次
String [][]str=new String[iRowCount][iColCount]; for (int i=1;i<iRowCount;i++) { HSSFRow row=sheet.getRow(i); if(sheet.getRow(i)!=null){ for(int j=0;j<iColCount;j++) { HSSFCell cell =row.getCell(j); if (cell!=null){ switch(cell.getCellType()) //判断类型 { case HSSFCell.CELL_TYPE_NUMERIC: //数字 cell_value=((Double)cell.getNumericCellValue()).toString().trim(); //cell_value=cell_value.substring(0,cell_value.length()); System.out.println("xxxxxxxx长度"+cell_value.length()); System.out.println("xxxxxxxx长度"+cell_value); break; case HSSFCell.CELL_TYPE_STRING: //字符串 cell_value=cell.getStringCellValue().toString().trim(); //cell_value = new String(cell_value.getBytes(), "utf-8"); //cell_value=encodeURI(cell_value); break; case HSSFCell.CELL_TYPE_FORMULA: //公式 cell_value= cell.getCellFormula().toString().trim(); break; case HSSFCell.CELL_TYPE_BLANK: // 空值 cell_value= " <font color=red> null </font> "; break; case HSSFCell.CELL_TYPE_ERROR: // 故障 break; default: //未知类型 cell_value= " <font color=red> null </font> "; break; } //end switch]); out.print(cell_value+ " "); //str[i][j]=cell_value=cell_value.substring(0,cell_value.length()-1); str[i][j]=cell_value.replace((char)12288,' ').replace(" ",""); //str[i][j]=cell_value.replace(" ","").trim(); System.out.println("第"+i+"行,第"+j+"列 :"+ str[i][j]); } //end if } //end for (short j = 0; j < iColCount; j++) { // out.print( " <br> "); } //end if(sheet.getRow(i)==null){ else { iRowCount++; System.out.println("fileToBeRead " + iRowCount); }