Skip to content

^ operator called on non-numeric base should return #VALUE! not 0 – minimal repro script included #2227

@nfcampos

Description

@nfcampos

EPPlus usage

Commercial use (I have a commercial license)

Environment

macos, linux

Epplus version

8.4.0

Spreadsheet application

Excel

Description

using OfficeOpenXml;

ExcelPackage.License.SetNonCommercialPersonal("witan repro");

using var pkg = new ExcelPackage();
var ws = pkg.Workbook.Worksheets.Add("Pow");

// In Excel: ="x"^2 returns #VALUE!.
ws.Cells["A1"].Value = "x";
ws.Cells["B1"].Formula = "A1^2";

Console.WriteLine("Before:");
Console.WriteLine($"  A1: value={ws.Cells["A1"].Value} text={ws.Cells["A1"].Text}");
Console.WriteLine($"  B1: value={ws.Cells["B1"].Value} text={ws.Cells["B1"].Text} formula={ws.Cells["B1"].Formula}");

Console.WriteLine();
Console.WriteLine("Cell.Calculate():");
ws.Cells["B1"].Calculate();
Console.WriteLine($"  B1: value={ws.Cells["B1"].Value} text={ws.Cells["B1"].Text}");

Console.WriteLine();
Console.WriteLine("Worksheet.Calculate(\"A1^2\"):");
Console.WriteLine($"  result={ws.Calculate("A1^2")}");
Before:
  A1: value=x text=x
  B1: value= text= formula=A1^2

Cell.Calculate():
  B1: value=0 text=0

Worksheet.Calculate("A1^2"):
  result=0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions