This project is read-only.

字符串连接公式出错

Feb 28, 2011 at 2:04 AM

在计算公式的时候会出错, 比如 A1的值是"str1", A2的值是"str2", A3的公司是 ==A1&B2, 这个时候计算A3的值的时候会出错
System.Exception: Unexpected operation ptg class (ConcatPtg).

下面是我取单元格值的方法

Row row = sheet.GetRow(rowNum - 1);
            if (row == null) return "";
            Cell cell = row.GetCell(colNum - 1);
            if (cell == null) return "";
            if (cell.CellType == NPOI.SS.UserModel.CellType.FORMULA)
            {
                HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet.Workbook);
                cell = evaluator.EvaluateInCell(cell);
            }
            return string.Format("{0}", cell);

Mar 17, 2011 at 8:57 AM

&目前不支持,你用 =CONCATENATE(A1,B1)试试