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

Created Unassigned: Removed Records: Named range from /xl/workbook.xml part (Workbook) [15497]

$
0
0
Hello, I am trying to edit an existing xlsx file that contains many pictures, named ranges, worksheets, and formatting. I perform the following code:

```
FileInfo newFile = new FileInfo("C:/test.xlsx");
ExcelPackage p = new ExcelPackage(newFile);
FileInfo saveAsFile = new FileInfo("C:/finished.xlsx");
p.SaveAs(saveAsFile);
```

As you can see, I am not editing this xlsx file in any way, but when I open the new "finished.xlsx", I get an error message telling me that there is a problem with some of the content. Then the log shows up and shows and error:

> Removed Records: Named range from /xl/workbook.xml part (Workbook)

I investigated this issue by exploring the before and after workbook.xml files and noticing one difference between the two. I've noted the difference with ### before the line

Before:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook mc:Ignorable="x15" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
<fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/>
<workbookPr codeName="ThisWorkbook"/>
<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<mc:Choice Requires="x15">
<x15ac:absPath url="C:\Users\dillo\Desktop\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/>
</mc:Choice>
</mc:AlternateContent>
<bookViews>
<workbookView activeTab="1" windowHeight="7180" windowWidth="15480" xWindow="120" yWindow="60"/>
</bookViews>
<sheets>
<sheet name="Change" r:id="rId1" sheetId="5"/>
<sheet name="R1Data" r:id="rId2" sheetId="1"/>
<sheet name="Mounts" r:id="rId3" sheetId="13"/>
<sheet name="Process" r:id="rId4" sheetId="11"/>
<sheet name="ST3 Base Frame" r:id="rId5" sheetId="10"/>
<sheet name="DCS User models" r:id="rId6" sheetId="14"/>
</sheets>
<externalReferences>
<externalReference r:id="rId7"/>
</externalReferences>
<definedNames>
<definedName localSheetId="0" name="_xlnm.Print_Area">Change!$A$1:$G$31</definedName>
<definedName localSheetId="2" name="_xlnm.Print_Area">Mounts!$A$1:$N$92</definedName>
<definedName localSheetId="3" name="_xlnm.Print_Area">Process!$A$1:$M$46</definedName>
<definedName localSheetId="1" name="_xlnm.Print_Area">'R1Data'!$A$1:$G$36</definedName>
<definedName localSheetId="4" name="_xlnm.Print_Area">'ST3 Base Frame'!$A$1:$M$23</definedName>
###<definedName name="Shape">[1]Sheet2!$A$1:$A$5</definedName>###
</definedNames>
<calcPr calcId="152511"/>
</workbook>
```


After:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook mc:Ignorable="x15" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
<fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/>
<workbookPr codeName="ThisWorkbook"/>
<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<mc:Choice Requires="x15">
<x15ac:absPath url="C:\Users\dillo\Desktop\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/>
</mc:Choice>
</mc:AlternateContent>
<bookViews>
<workbookView activeTab="1" windowHeight="7180" windowWidth="15480" xWindow="120" yWindow="60"/>
</bookViews>
<sheets>
<sheet name="Change" r:id="rId1" sheetId="5"/>
<sheet name="R1Data" r:id="rId2" sheetId="1"/>
<sheet name="Mounts" r:id="rId3" sheetId="13"/>
<sheet name="Process" r:id="rId4" sheetId="11"/>
<sheet name="ST3 Base Frame" r:id="rId5" sheetId="10"/>
<sheet name="DCS User models" r:id="rId6" sheetId="14"/>
</sheets>
<externalReferences>
<externalReference r:id="rId7"/>
</externalReferences>
<definedNames>
###<definedName name="Shape">[file:///\\bramalea\Archive\MAS\2015\Jobs\4245-Karmax%20CD4.2%20Rear%20Rails\___Automation\4245_Karmax_CD4_2\Robotics\Robot%20setup\DCS%20files\ZONE_1%20LH\10R01_DCS_LH.xlsx]Sheet2!$A$1:$A$5</definedName>###
<definedName localSheetId="0" name="_xlnm.Print_Area">'Change'!$A$1:$G$31</definedName>
<definedName localSheetId="1" name="_xlnm.Print_Area">'R1Data'!$A$1:$G$36</definedName>
<definedName localSheetId="2" name="_xlnm.Print_Area">'Mounts'!$A$1:$N$92</definedName>
<definedName localSheetId="3" name="_xlnm.Print_Area">'Process'!$A$1:$M$46</definedName>
<definedName localSheetId="4" name="_xlnm.Print_Area">'ST3 Base Frame'!$A$1:$M$23</definedName>
</definedNames>
<calcPr calcId="152511" fullCalcOnLoad="1"/>
</workbook>
```

How can I fix this issue?

Commented Unassigned: Creating a Comment with an empty Author leads to corrupt Excel file [15358]

$
0
0
Hi EPPlus developers,

a fix from 01 Sept 2015 (65115680ca04) on ___ExcelRangeBase.AddComment___ invoked some deeper problem, which existed already before.
Creating a Comment with an empty Author
```
package.Workbook.Worksheets.First().Cells["A1"].AddComment("Text", String.Empty);
```
will lead to a cell with no __authorId__ attribute
```
<comments xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<authors/>
<commentList>
<comment ref="D1" >
<text>
...
```
This is not allowed by specification. See ___18.7.1 author (Author)___

> This element holds a string representing the name of a single author of comments. Every comment shall have an author.


Excel does not want to open these files either and repares them by deleting the whole comment tag. I think this is not crucial, if you will allow emty Author again. By the way, if ___Author___ property of ___ExcelComment___ class is read, when it was never set before - it throws a NullReferenceException.

Comments: Perhaps EPPlus can throw an __ArgumentException__ if a null/empty author value is used? That will make debugging much easier :-)

Commented Unassigned: Removed Records: Named range from /xl/workbook.xml part (Workbook) [15497]

$
0
0
Hello, I am trying to edit an existing xlsx file that contains many pictures, named ranges, worksheets, and formatting. I perform the following code:

```
FileInfo newFile = new FileInfo("C:/test.xlsx");
ExcelPackage p = new ExcelPackage(newFile);
FileInfo saveAsFile = new FileInfo("C:/finished.xlsx");
p.SaveAs(saveAsFile);
```

As you can see, I am not editing this xlsx file in any way, but when I open the new "finished.xlsx", I get an error message telling me that there is a problem with some of the content. Then the log shows up and shows and error:

> Removed Records: Named range from /xl/workbook.xml part (Workbook)

I investigated this issue by exploring the before and after workbook.xml files and noticing one difference between the two. I've noted the difference with ### before the line

Before:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook mc:Ignorable="x15" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
<fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/>
<workbookPr codeName="ThisWorkbook"/>
<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<mc:Choice Requires="x15">
<x15ac:absPath url="C:\Users\dillo\Desktop\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/>
</mc:Choice>
</mc:AlternateContent>
<bookViews>
<workbookView activeTab="1" windowHeight="7180" windowWidth="15480" xWindow="120" yWindow="60"/>
</bookViews>
<sheets>
<sheet name="Change" r:id="rId1" sheetId="5"/>
<sheet name="R1Data" r:id="rId2" sheetId="1"/>
<sheet name="Mounts" r:id="rId3" sheetId="13"/>
<sheet name="Process" r:id="rId4" sheetId="11"/>
<sheet name="ST3 Base Frame" r:id="rId5" sheetId="10"/>
<sheet name="DCS User models" r:id="rId6" sheetId="14"/>
</sheets>
<externalReferences>
<externalReference r:id="rId7"/>
</externalReferences>
<definedNames>
<definedName localSheetId="0" name="_xlnm.Print_Area">Change!$A$1:$G$31</definedName>
<definedName localSheetId="2" name="_xlnm.Print_Area">Mounts!$A$1:$N$92</definedName>
<definedName localSheetId="3" name="_xlnm.Print_Area">Process!$A$1:$M$46</definedName>
<definedName localSheetId="1" name="_xlnm.Print_Area">'R1Data'!$A$1:$G$36</definedName>
<definedName localSheetId="4" name="_xlnm.Print_Area">'ST3 Base Frame'!$A$1:$M$23</definedName>
###<definedName name="Shape">[1]Sheet2!$A$1:$A$5</definedName>###
</definedNames>
<calcPr calcId="152511"/>
</workbook>
```


After:

```
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<workbook mc:Ignorable="x15" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:x15="http://schemas.microsoft.com/office/spreadsheetml/2010/11/main">
<fileVersion appName="xl" lastEdited="6" lowestEdited="6" rupBuild="14420"/>
<workbookPr codeName="ThisWorkbook"/>
<mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
<mc:Choice Requires="x15">
<x15ac:absPath url="C:\Users\dillo\Desktop\" xmlns:x15ac="http://schemas.microsoft.com/office/spreadsheetml/2010/11/ac"/>
</mc:Choice>
</mc:AlternateContent>
<bookViews>
<workbookView activeTab="1" windowHeight="7180" windowWidth="15480" xWindow="120" yWindow="60"/>
</bookViews>
<sheets>
<sheet name="Change" r:id="rId1" sheetId="5"/>
<sheet name="R1Data" r:id="rId2" sheetId="1"/>
<sheet name="Mounts" r:id="rId3" sheetId="13"/>
<sheet name="Process" r:id="rId4" sheetId="11"/>
<sheet name="ST3 Base Frame" r:id="rId5" sheetId="10"/>
<sheet name="DCS User models" r:id="rId6" sheetId="14"/>
</sheets>
<externalReferences>
<externalReference r:id="rId7"/>
</externalReferences>
<definedNames>
###<definedName name="Shape">[file:///\\bramalea\Archive\MAS\2015\Jobs\4245-Karmax%20CD4.2%20Rear%20Rails\___Automation\4245_Karmax_CD4_2\Robotics\Robot%20setup\DCS%20files\ZONE_1%20LH\10R01_DCS_LH.xlsx]Sheet2!$A$1:$A$5</definedName>###
<definedName localSheetId="0" name="_xlnm.Print_Area">'Change'!$A$1:$G$31</definedName>
<definedName localSheetId="1" name="_xlnm.Print_Area">'R1Data'!$A$1:$G$36</definedName>
<definedName localSheetId="2" name="_xlnm.Print_Area">'Mounts'!$A$1:$N$92</definedName>
<definedName localSheetId="3" name="_xlnm.Print_Area">'Process'!$A$1:$M$46</definedName>
<definedName localSheetId="4" name="_xlnm.Print_Area">'ST3 Base Frame'!$A$1:$M$23</definedName>
</definedNames>
<calcPr calcId="152511" fullCalcOnLoad="1"/>
</workbook>
```

How can I fix this issue?
Comments: Could you upload your workbook as an attachment to this issue?

Commented Unassigned: ExcelDrawing.SetPosition(int Row, int RowOffsetPixels, int Column, int ColumnOffsetPixels) Broken with release 4.1.0 [15495]

$
0
0
Discovered while anchoring an ExcelPicture to a specific row and column.

This works fine in 4.0.5 but with release 4.1.0 SetPosition() does not seem to honor the column parameter, instead everything appears in first column. Which is fine I guess, if that's where you wanted it in the first place :)
Comments: Hi, I just tested the current sourcecode with the following unit test and it seems to work as expected. Could you share a similar test that produces the error? ``` [TestMethod] public void AnchorDrawingToCol() { using (var package = new ExcelPackage()) { var sheet = package.Workbook.Worksheets.Add("test"); var drawing = sheet.Drawings.AddShape("testDrawing", eShapeStyle.Cube); drawing.SetSize(200, 200); drawing.Fill.Style = eFillStyle.SolidFill; drawing.Fill.Color = Color.Aqua; drawing.SetPosition(2, 0, 2, 0); package.SaveAs(new FileInfo(@"c:\Development\TestData\drawing.xlsx")); } } ```

Commented Unassigned: EPPlus: Created file is locked [14919]

$
0
0
I create an Excel file using EPPlus library. After the file is created, it cannot be deleted or edited, as it is said to be used by "another user", as long as the program is running. I cannot find any solution that would work for me.

```
Here is my code:

var newFile = new FileInfo(path);
using (var xlPackage = new ExcelPackage(newFile))
{
var ws = xlPackage.Workbook.Worksheets.Add("Sheet1");
...
xlPackage.Save();
}
```

The strange thing is that I am able File.Delete() the newly created files from within my code. But I cannot delete or edit it while the program is still running from the Windows Explorer.
Comments: I have the same behavior on while using EPPLUS in SSIS. From my point of view, this is a major issue as it might force my project to move away from EPPLUS and redevelop a lot of code. I would really appreciate a workaround or a fix to this issue..

Created Unassigned: FormulaR1C1 parser messing with formula [15498]

$
0
0
Test case:
//_ws is some worksheet.
var deptColumn = 59;
var startRow = 5;
var k = 5;
var i = 70;

var formulaStr = $@"=SUMIF(R5C{deptColumn}:R{i + startRow}C{deptColumn};""="" & RC{deptColumn};R5C{k}:R{i + startRow}C{k})";

What I Expect:
Cell formula should be:
SUMIF(R5C59:R75C59;"=" & RC59;R5C5:R75C5)";

What I get in case _ws.Cells[i,k].FormulaR1C1 = formulaStr;
SUMIF(R5C59:"="R81C59; & RC59;R5C6:R81C6)"

What I get in case _ws.Cells[i,k].Formula = formulaStr;
"=SUMIF(R5C59:R81C59;"=" & RC59;R5C6:R81C6)"

Somehow "=" moved left if I use FormulaR1C1 parser

Created Unassigned: Error creating excel from a template with PivotTable [15499]

$
0
0
I'm using an excel template which contains a pivottable and what I do is add rows to the data source is a table but in the result generates an error. the data source is a table but the result adds a range.

Showing the error when opening the excel result is:

"Feature removed: PivotTable Report /xl/pivotCache/pivotCacheDefinition1.xml part (PivotTable cache)
Feature removed: Report /xl/pivotTables/pivotTable1.xml part PivotTable (PivotTable view)
Records removed: Properties /xl/workbook.xml part book (Book)"

to review the file

xl/pivotCache/pivotCacheDefinition1.xml

Before:

<WorksheetSource name= "Tabla1" />

After:

<WorksheetSource name= "Tabla1" __ref= "A1: B3"__ />

I'm just adding rows to the data source but adds "ref". if I delete "ref" if properly load generated excel.

Created Unassigned: Shared Formula exceptions configured in Excel are overwritten when splitting Shared Formulas in EP Plus. [15500]

$
0
0
In Excel, a shared formula is defined over a range of cells. If one of those cells' formulas is overwritten with some other formula, the original shared formula range remains intact but that cell has an actual formula instead of a shared formula ID.

I've attached a workbook that I created in Excel.
If you inspect the OpenXml you will see that a shared formula was defined over C4:C6.
I then explicitly set a formula in C5.

If you open the attached workbook in EP Plus and overwrite the formula in C4, you will see that the formula in C5 is converted back into the shared formula that it "inherited" from C4.

This occurs due to the shared formula splitting that occurs when updating shared formulas. There is a built-in assumption that any cell in the shared formula range really does contain that shared formula. This is a safe assumption for any shared ranges created in EP Plus due to the splitting algorithm, but it does not account for the Excel representation of the case.

Commented Unassigned: Shared Formula exceptions configured in Excel are overwritten when splitting Shared Formulas in EP Plus. [15500]

$
0
0
In Excel, a shared formula is defined over a range of cells. If one of those cells' formulas is overwritten with some other formula, the original shared formula range remains intact but that cell has an actual formula instead of a shared formula ID.

I've attached a workbook that I created in Excel.
If you inspect the OpenXml you will see that a shared formula was defined over C4:C6.
I then explicitly set a formula in C5.

If you open the attached workbook in EP Plus and overwrite the formula in C4, you will see that the formula in C5 is converted back into the shared formula that it "inherited" from C4.

This occurs due to the shared formula splitting that occurs when updating shared formulas. There is a built-in assumption that any cell in the shared formula range really does contain that shared formula. This is a safe assumption for any shared ranges created in EP Plus due to the splitting algorithm, but it does not account for the Excel representation of the case.
Comments: This is being addressed in fork: https://hg.codeplex.com/forks/zpffpz/sharedformulasplitting

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);
}
}
```

Edited 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.Cells[3, 3].Calculate();
Assert.AreEqual(new List<object> { "test1", "test2" }, worksheet.Cells[3, 3].Value);
}
}
```

Edited 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.Cells[3, 3].Calculate();
Assert.AreEqual(new List<object> { "test1", "test2" }, worksheet.Cells[3, 3].Value);
}
}
```

Edited 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.Cells[3, 3].Calculate();
Assert.AreEqual(new List<object> { "test1", "test2" }, worksheet.Cells[3, 3].Value);
}
}
```

Created Unassigned: ExcelHeaderFooter.ScaleWithDoc property missing in EPPlus 4.1.0 [15502]

$
0
0
The ExcelHeaderFooter.ScaleWithDoc property is missing in EPPlus 4.1.0.
It is implemented in EPPlus 3.

I have implemented this extension method in my code as a workaround:

public static void SetScaleWithDocToFalse(this ExcelWorksheet worksheet)
{
//worksheet.HeaderFooter.ScaleWithDoc = false; //NOTE: This is not implemented in EPPlus 4
var scaleWithDoc = worksheet.WorksheetXml.CreateAttribute("scaleWithDoc");
scaleWithDoc.Value = "0";
var headerFooterAttributes = worksheet.WorksheetXml.GetElementsByTagName("headerFooter")[0].Attributes;
headerFooterAttributes?.Append(scaleWithDoc);
}

Created Unassigned: ExcelAddress has "" for WorkSheet [15503]

$
0
0
The _public ExcelAddress(int fromRow, int fromCol, int toRow, int toColumn);_ constructor causes the non-public _WorkSheet_ prooperty (and __ws_ variable) to be set to "" instead of _null_. This causes my code to add a table to a worksheet to fail:

```
ExcelAddress tableRange = new ExcelAddress(headerCells.Start.Row, headerCells.Start.Column, headerCells.End.Row + rowCount, headerCells.End.Column);
ExcelTable table = headerCells.Worksheet.Tables.Add(tableRange, newTableName);
```

Attaching with the debugger and changing the value to null allows the code to run, but there is no way to fix this without the debugger.
The code worked in a previous version (3.5 I think).

Resulting error message (System.ArgumentException):
> Range does not belong to worksheet
> Parameter name: Range

Commented Unassigned: Removing Comments Issue [15432]

$
0
0
Hello,

We're using version 4.0.5 of EP Plus, which is generally working very well, so thanks for developing this excellent library. We've encountered one issue recently that we're unable to work around when removing comments. These can successfully remove comments using the following code -

workSheet.Comments.Remove(workSheet.Cells[row, col].Comment);

and then after saving the spreadsheet opens successfully in excel and the comments are gone.

However, the next time we open this and then loop through the cells we get an XmlException thrown when checking the comments on this line -

if (workSheet.Cells[row, col].Comment != null)

Currently then we have to set the comment to be an empty string, but excel views this as a comment and so the red comment marker is still appended to the cell in question.

The exception thrown is -

System.Xml.XmlException: Data at the root level is invalid. Line 41, position 7.
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace()
at System.Xml.XmlTextReaderImpl.ParseDocumentContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
at System.Xml.XmlDocument.Load(XmlReader reader)
at OfficeOpenXml.XmlHelper.LoadXmlSafe(XmlDocument xmlDoc, Stream stream)
at OfficeOpenXml.Drawing.Vml.ExcelVmlDrawingBaseCollection..ctor(ExcelPackage pck, ExcelWorksheet ws, Uri uri)
at OfficeOpenXml.Drawing.Vml.ExcelVmlDrawingCommentCollection..ctor(ExcelPackage pck, ExcelWorksheet ws, Uri uri)
at OfficeOpenXml.ExcelWorksheet.CreateVmlCollection()
at OfficeOpenXml.ExcelWorksheet.get_Comments()
at OfficeOpenXml.ExcelRangeBase.get_Comment()
at ExcelServices.Helpers.ExcelFileHelper.RemoveCommentsAndCellFormatting(ExcelWorksheet workSheet) in c:\TFS\Projects\CRM\Ada\ExcelServices\Helpers\ExcelFileHelper.cs:line 39
at ExcelServices.ImportFileProcessor.ValidateWorkSheet(ExcelWorksheet workSheet) in c:\TFS\Projects\CRM\Ada\ExcelServices\ImportFileProcessor.cs:line 200
at ExcelServices.ImportFileProcessor.ProcessFile(String fileName, Boolean update, Action importAction) in c:\TFS\Projects\CRM\Ada\ExcelServices\ImportFileProcessor.cs:line 155


Any help in resolving this would be much appreciated.
Comments: Confirmed the problem, but I had no drawings. Just delete any large and re-open, problem happens right away. Surprised this isn't being worked on.

Commented Unassigned: ExcelAddress has "" for WorkSheet [15503]

$
0
0
The _public ExcelAddress(int fromRow, int fromCol, int toRow, int toColumn);_ constructor causes the non-public _WorkSheet_ prooperty (and __ws_ variable) to be set to "" instead of _null_. This causes my code to add a table to a worksheet to fail:

```
ExcelAddress tableRange = new ExcelAddress(headerCells.Start.Row, headerCells.Start.Column, headerCells.End.Row + rowCount, headerCells.End.Column);
ExcelTable table = headerCells.Worksheet.Tables.Add(tableRange, newTableName);
```

Attaching with the debugger and changing the value to null allows the code to run, but there is no way to fix this without the debugger.
The code worked in a previous version (3.5 I think).

Resulting error message (System.ArgumentException):
> Range does not belong to worksheet
> Parameter name: Range
Comments: I found a work around: ``` ExcelAddress tableRange = new ExcelAddress(headerCells.Start.Row, headerCells.Start.Column, headerCells.End.Row + rowCount, headerCells.End.Column); //The above ExcelAddress constructor does not properly clear the worksheet name (uses "" instead of null). This code works around the bug. string worksheetName = '\'' + headerCells.Worksheet.Name.Replace("\'", "'") + '\''; //get the safe version of the worksheet name. tableRange = new ExcelAddress(worksheetName + "!" + tableRange.Address); //Create a new ExcelAddress using the string representation, including the worksheet name. ExcelTable table = headerCells.Worksheet.Tables.Add(tableRange, newTableName); ```

Created Unassigned: Pivot table creation from downloaded excel file does not give expected result [15504]

$
0
0
We are allowing user to download the report as an excel format, we are using epplus to provide the end user the download facility. When user download the report as an excel format and try to create a Pivot Table then they empty cells are also consider in the count.

But after downloading the excel and user manually select the excel cell with empty value and press the delete button then pivot table gives the expected result.

I think epplus add an empty value in the cell for the null field but it should keep the cell as blank.

Is there any work around to fix this issue.

Created Unassigned: Pivot Table Field Sub Totals causes excel data corruption [15505]

$
0
0
When I set a Pivot Table Field's Sub Total to none, the resulting excel file that I open says that the data is corrupt and asks if excel should try to recover the data.

the code that is causing the issue is:

var field = currentPivotTable.Fields[_fieldName];

field.SubTotalFunctions = OfficeOpenXml.Table.PivotTable.eSubTotalFunctions.None;

currentPivotTable.RowFields.Add(field);


Created Unassigned: Issue with Named Styles [15506]

$
0
0
In the version 4.1 following code throws exception:

```
ens = ep.Workbook.Styles.CreateNamedStyle("Test")
Dim bTestOK As Boolean = ens.Style.WrapText
ens.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center
Dim bTestNG As Boolean = ens.Style.WrapText
```


Here are the exception details.


```
=== System.ArgumentOutOfRangeException =========================
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
----------------------------
Source: mscorlib
----------------------------
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.Collections.Generic.List`1.get_Item(Int32 index)
at OfficeOpenXml.ExcelStyleCollection`1.get_Item(Int32 PositionID) in <path>\EPPlus\36\e1834888\ExcelStyleCollection`1.cs:line 30
at OfficeOpenXml.Style.ExcelStyle.get_WrapText() in <path>\EPPlus\52\de9556c8\ExcelStyle.cs:line 60
```

Each time the style is changing an internal hash key of all values is created for inventory of identical styles and stored in Id property.
For example

```
General|Calibri110FFFFNone|None0000|None00None00None00None00None00FalseFalse|Bottom|General|False|ContextDependent|1|False
```

The hash key includes XfId at the second to last location.
I think this could be a mistake and should not be a part of the hash key.

Workaround for the issue is to save and re-open the file before accessing attributes of the Named Styles.

Viewing all 2262 articles
Browse latest View live