发新话题
打印

写jexcel api公式,出现单元格都变成 a1

写jexcel api公式,出现单元格都变成 a1

用 jxl,来输出公式,比如 SUM(B4:H9) ,代码如下:

new jxl.write.Formula(x, y, "SUM(B4:H9)");   

但打开excel时,这个单元格,都变成了 SUM(A1:A1), 晕, 下载最新版本 jexcel api 2.6.12,就没问题.
经分析代码,得知里面
复制内容到剪贴板
代码:
public CellReference(String s, int row, int column)
  {
    if (s.startsWith("$[")) {
      this.columnRelative = (this.rowRelative );
      s = s.substring(2, s.indexOf(']'));
      String[] subindex = s.split(",");
      this.row = (Integer.parseInt(subindex[0]) + row);
      this.column = (Integer.parseInt(subindex[1]) + column);
    }
    else {
     
      column = CellReferenceHelper.getColumn(s);
      row = CellReferenceHelper.getRow(s);
      this.columnRelative = CellReferenceHelper.isColumnRelative(s);
      this.rowRelative = CellReferenceHelper.isRowRelative(s);
    }
  }
其中下面两行,应该加 this.方为正解
      column = CellReferenceHelper.getColumn(s);
      row = CellReferenceHelper.getRow(s);

TOP

发新话题