本帖最后由 hao1314 于 2011-04-26 22:30:35 编辑

解决方案 »

  1.   

    你所谓的别名是什么意思??? 在Excel手动做个Demo贴出图来 
      

  2.   

    package SwingDeo;
    import java.util.*;
    import org.apache.poi.xssf.usermodel.XSSFCell;
    import org.apache.poi.xssf.usermodel.XSSFRow;
    import org.apache.poi.xssf.usermodel.XSSFSheet;
    import org.apache.poi.xssf.usermodel.XSSFWorkbook;
    public class PoiService {
     private String strPath;
     public PoiService(String strPath) {
      this.strPath = strPath;
     }
     public List<String> getSheetCellValues() throws Exception {
      ArrayList<String> list = new ArrayList<String>();
      XSSFWorkbook xwb = new XSSFWorkbook(strPath);
      XSSFSheet xSheet = xwb.getSheet("Sheet1");
      // Row
      for (int rowNum = 0; rowNum <= xSheet.getLastRowNum(); rowNum++) {
       XSSFRow xRow = xSheet.getRow(rowNum);
       if (xRow == null) {
        continue;
       }
       // Cell
       XSSFCell xCell = xRow.getCell(1);
       if (xCell == null) {
        continue;
       }
       if (xCell.getCellType() == XSSFCell.CELL_TYPE_STRING) {
    String s = xCell.getRowIndex()+Integer.parseInt("1")+": "+xCell.getStringCellValue();
    list.add(s);
    }
        }
      return list;
       }
    }