HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow(0);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell(0);如果只知道列是"AB"列怎么办?需求:客户只给程序传递EXCEL列参数,由程序返回值,但客户只知道列的英文字母,不知道列号.API里没有RANGE取单元格对象吗???在线等!!!

解决方案 »

  1.   

    没说太清楚,不想用循环数组和MAP的方法,有没有效率高的方法.
    1.数组:String str[] = {"A","B","C","D","E","F".....,"ZZ"};
    2.HashMap:  
      HashMap map = new HashMap();
      map.put("A","0");
      map.put("B","1");
      map.put("C","2");
      map.put("D","3");
      map.put("E","4");
      .....
      map.put("ZZ","255");在线等达人!!
      

  2.   

    A 0
    B 1
    C 2
    .
    .
    .
    Z 25
    AA 26*1+0=26
    AB 26*1+1=27
    .
    .
    .
    AZ 26*1+25=51
    BA 26*2+0=52
    .
    .
    .呃——进制转换啊,很明显的规律吧
      

  3.   

    在CSDN想排好版是件很难的事……
      

  4.   

    public static int GetCellNum(String strCellName){
    String subCellName1 = strCellName.substring(0,1);

    String strAToZ ="ABCDEFGHIJKLMNOPQRSTUVWXYZ"; 
    int intCellNum = 0;
    if (strCellName.length() >1){
    String subCellName2 = strCellName.substring(1,2);
    intCellNum =(int)(strAToZ.indexOf(subCellName1)+1)*26 + strAToZ.indexOf(subCellName2);
    }else{
    intCellNum = strAToZ.indexOf(strCellName);
    }
    return intCellNum;
    }搞定,结贴!