A类里有个方法:
public void setA () {
  try {
    ******
    // 1
  } catch (Exception e) {
    e.printStackTrace();
  }
}B类里调用这个方法:
public static void main(String [] args) {
  setA();
  // 2
}A,B同包。在1和2处分别写上输出语句,输出在方法setA()里设置的内容,结果1处有显示,2处打印出null!请问这是为什么?

解决方案 »

  1.   

    give more detail and make you problem more clear
      

  2.   

    ExcelColumnUtil类中
    public void setBodyDefaultLocation (ExcelColumnUtil ecu, List bodyList, int cols, int i) {
    ecu.setRow(5 + i / cols);
    ecu.setCol(i % cols + 1);
    ecu = new ExcelColumnUtil(ws, ecu.getRow(), ecu.getCol(), 360, 12, bodyList.get(i)
    .toString(), "宋体", "10", true, "LEFT", "BLACK", "WHITE");
    WritableCellFormat wcf = ecu.setCharacterFormat();
    try {
    ecu.setCellFormat(wcf);
    System.out.println("1" + ecu.getCellValue());
    } catch (Exception e) {
    e.printStackTrace();
    }
    }"1"
    }
    B类中
    public static void main(String [] args) {
    ExcelColumnUtil ecuBody = new ExcelColumnUtil();
            WritableCellFormat wcf = null;
            for (int i = 0; i < bodyList.size(); i ++) {
             eu.setBodyDefaultLocation(ecuBody, bodyList, eu.cols, i);
    System.out.println("2"+ ecuBody.getCellValue());
    }
    }Result:1后有内容,2后都为null
      

  3.   

    more and more about getCellValue(); 2 not find setCellFormat(wcf); but 1 use
      

  4.   

    Thanks, I'll check it again.