Quantcast
Channel: EPPlus Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 2262

Created Unassigned: Arrays are not handled correctly by logical operators and some functions. [15501]

$
0
0
It seems that certain functions in EPPlus don't deal with arrays the same way as Excel. In some cases the comparisons return the wrong value, and in others #VALUE errors are returned.

See below for failing tests that should pass according to the behavior in Excel.

```
[TestMethod]
public void IfWithArray()
{
using (ExcelPackage package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells[3, 3].Formula = "IF(FALSE,\"true\",{\"false\"})";
worksheet.Cells[3, 3].Calculate();
Assert.AreEqual("false", worksheet.Cells[3, 3].Value);
}
}

[TestMethod]
public void SumIfWithArray()
{
using (ExcelPackage package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells[2, 2].Formula = "{1,2,3}";
worksheet.Cells[2, 3].Formula = "1";
worksheet.Cells[3, 3].Formula = "SUMIF(B2,\"{1,2,3}\",C2)";
worksheet.Cells[3, 3].Calculate();
Assert.AreEqual(1d, worksheet.Cells[3, 3].Value);
}
}

[TestMethod]
public void ArrayEquality()
{
using (ExcelPackage package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells[3, 3].Formula = "{\"test\"}=\"test\"";
worksheet.Cells[3, 4].Formula = "{\"test\"}=\"\"\"test\"\"\"\";
worksheet.Cells[3, 5].Formula = "{\"test1\",\"test2\"}=\"test1\"";
worksheet.Cells[3, 6].Formula = "{\"test1\",\"test2\"}={\"test1\"}";
worksheet.Cells[3, 7].Formula = "{\"test1\",\"test2\"}={\"test1\",\"testB\"}";
worksheet.Cells[3, 8].Formula = "{1,2,3}+4";
worksheet.Calculate();
Assert.IsTrue((bool)worksheet.Cells[3, 3].Value);
Assert.IsFalse((bool)worksheet.Cells[3, 4].Value);
Assert.IsTrue((bool)worksheet.Cells[3, 5].Value);
Assert.IsTrue((bool)worksheet.Cells[3, 6].Value);
Assert.IsTrue((bool)worksheet.Cells[3, 7].Value);
Assert.AreEqual(5d, worksheet.Cells[3, 8].Value);
}
}

[TestMethod]
public void ArrayCell()
{
using (ExcelPackage package = new ExcelPackage())
{
var worksheet = package.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells[3, 3].Formula = "{\"test1\",\"test2\"}";
worksheet.Calculate();
Assert.AreEqual(new List<object> { "test1", "test2" }, worksheet.Cells[3, 3].Value);
}
}
```

Viewing all articles
Browse latest Browse all 2262

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>