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

Commented Unassigned: Excel cannot open password protected package [15540]

$
0
0
When I try to open a password protected file, after typing the password into the pop-up Excel then displays the error message:

"Excel cannot open the file 'myfile.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

Recreate it with code like this:

```
ExcelPackage package = new ExcelPackage();

var sheet = package.Workbook.Worksheets.Add("Sheet 1");

package.Encryption.Password = "mypassword";

using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create))
{
package.SaveAs(fs);
}
```

package.Encryption.Version is set to EncryptionVersion.Agile, but I did try changing it to EncryptionVersion.Standard with

```
package.Encryption.Version = EncryptionVersion.Standard;
```

and that didn't help either. Nor did using the alternative SaveAs signature of

```
package.SaveAs(fs, "myPassword");
```

I'm using Excel 2013 on Windows 10 Pro 64-bit. This was working fine: maybe there has been a recent Windows or Excel update that broke it?
Comments: In case I wasn't clear, opening the file without the password is fine e.g. a file generated with ``` ExcelPackage package = new ExcelPackage(); var sheet = package.Workbook.Worksheets.Add("Sheet 1"); using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create)) { package.SaveAs(fs); } ``` opens ok.

Commented Unassigned: Excel cannot open password protected package [15540]

$
0
0
When I try to open a password protected file, after typing the password into the pop-up Excel then displays the error message:

"Excel cannot open the file 'myfile.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

Recreate it with code like this:

```
ExcelPackage package = new ExcelPackage();

var sheet = package.Workbook.Worksheets.Add("Sheet 1");

package.Encryption.Password = "mypassword";

using (var fs = new FileStream("C:\\my\\path\\myFile.xlsx", FileMode.Create))
{
package.SaveAs(fs);
}
```

package.Encryption.Version is set to EncryptionVersion.Agile, but I did try changing it to EncryptionVersion.Standard with

```
package.Encryption.Version = EncryptionVersion.Standard;
```

and that didn't help either. Nor did using the alternative SaveAs signature of

```
package.SaveAs(fs, "myPassword");
```

I'm using Excel 2013 on Windows 10 Pro 64-bit. This was working fine: maybe there has been a recent Windows or Excel update that broke it?
Comments: Forgot to say: I'm using version 4.1.0 from NuGet

Commented Unassigned: Excel in email attachment gets filtered [15294]

$
0
0
I am using EPPLUS version 4.0.0.0 for excel automation

I have tried using file signature as .xlsx for the automatically created excel and saved in the disk.

Excel file is getting created with the contents but when I attach it in email, the attachment turns into a text file with the text "This attachment was removed".

I can't use some other versions of EPPLUS in my application as I use this version for excel export functionality.

So please let me know the file signature to be used for the excel in email attachment using EPPLUS 4.0.0.0.


Comments: > Why is this issue still not solved in version 4.1? It should be easy... Exactly! I descibed the fix a year ago. They need just comment one line of code. I do not understand what they are waiting for.

Created Unassigned: ExcelWorksheet.SetValue throws ArgumentException [15541]

$
0
0
__ExcelWorksheet.SetValue(int,int,Object)__ throws an unexpected __System.ArgumentException__ caused by an invalid __System.Array.Copy__ in __CellStore.AddCell__. I suspect this exception occurs only when __CellStore.SplitPage__ creates a page for exactly _(2^n)_ rows. Then __CellStore<int>.GetSize__ will return the same value _(2^n)_ and the __CellStore.PageIndex.RowCount__ of this page will be equal to __CellStore.PageIndex.Rows.Length__. However, the page for the new cell should have at least one extra row available for that cell; otherwise __System.Array.Copy__ will throw an exception.

Created Unassigned: Create pivate table using template [15542]

$
0
0
Hi,

I would like to know if its possible to geberate pivot table using an template.

I have a template file which has 2 worksheets.
1: datasource ( only header row)
2: Pivot table

I use this template to to create an excel file with data on sheet 1.
the pivot table on the other worksheet do not get generated using this template.

Generating sheet 1 ( datasource) using template works. but pivot table worksheet do not get formed.
Can any one help me out with this.

Regards
Trevor

Created Unassigned: Styling charts with built-in eChartStyle enum does not conform to the built-int styles of Excel. [15543]

$
0
0
Hi,

I'm trying to style a normal bar chart and a pivot pie chart using the built-in Excel styles. However I ran a loop and generated a chart with each of the available enum (eChartStyle) options, and none of the styles look like the built-int styles available in MS Office Home and Business 2016. Is this a known issue, or am I going about it incorrectly?

Created Unassigned: ConditionalFormatting not working [15544]

$
0
0
When creating conditional formatting with "AddExpression" function, conditional format can be visible by opening generated file in Excel but has to be open and closed in order to make it work

Commented Unassigned: Add support for manipulating chart grid lines. [15440]

$
0
0
There's currently no way of removing/manipulating grid lines in charts. It would be nice if this functionality was exposed.
Comments: Hi, There is no better way, however you can still achieve it using below code. System.Xml.XmlNodeList nl = chart.ChartXml.GetElementsByTagName("c:majorGridlines"); for (int i = 0; i < nl.Count; i++) { nl[i].ParentNode.RemoveChild(nl[i]); }

Commented Unassigned: .NET Core Support [15472]

$
0
0
now that we have the new NET Platform Standard system and .net core rc2 might be the time for this features?
Comments: This is currently among our top concerns so it would be greatly appreciated with .NET Core support. We are dependent on a service for providing EPPlus functionality and temporarily have succumbed to do that with .NET Bloated.

Created Unassigned: Merging single cell range results to corrupted file [15545]

$
0
0
When you set Merge = True to a single cell range, it gets saved to the destination sheet as :
```
<mergeCells>
<mergeCell ref="K21" />
</mergeCells>
```

This is incompatible with (at least) Microsoft Excel 2013: you cannot merge a single cell.
As a result the saved file is corrupted but can be fully repared by Excel.

I propose to update ExcelRangeBase.Merge property to prevent adding single cells.

Created Unassigned: DataValidation element cannot be created (resulting in corrupt file) [15546]

$
0
0
I am usung a file that has a datavalidation element. When I load that file and remove the existing DataValidation item then the root item "DataValidations" will be removed. That is ok.
But when I add a new DataValidation item then the internal function "ExcelDataValidation.cs" -> "EnsureRootElementExists()" will not create the required "DataValidations" item.
I am using the following workaround:
```
private void EnsureRootElementExists()
{
var node = _worksheet.WorksheetXml.SelectSingleNode(DataValidationPath, _worksheet.NameSpaceManager);
if (node == null)
{
TopNode = _worksheet.WorksheetXml.DocumentElement; // This line fixes the problem
CreateNode(DataValidationPath.TrimStart('/'));
}
}
```

The problem is that "CreateNode" requires "TopNode" to be the sheet. TopNode is overwritten by "GetRootNode".

Created Unassigned: Adding VBA to a file can lead to a corrupted file (sheetPr) [15547]

$
0
0
When loading a file and then using this line:
```
package.Workbook.CreateVBAProject();
```
the file can get corrupted. This happens because <sheetPr codeName="" ...> is changed or set incorrectly.
I noticed that the "codeName" should be at max 22 chars long, but there are examples where longer names do work fine.
Examples:
```
<sheetPr codeName="This is a longer name abC" is ok and 25 characters long
<sheetPr codeName="1-This is a longer name a" is not ok and 25 characters long
<sheetPr codeName="1-This is a longer name" is not ok and 23 characters long
<sheetPr codeName="1-This is a longer nam" is ok and 22 characters long
```

Currently I have two workarounds which are not good.
1) Get "codeName" of all sheets, use the "CreateVBAProject" function and restore the "codeName"s
2) Use the "CreateVBAProject" function and trim the "codeName"s to 22 chars.

Best fix would be to not update the "codeName" if it exists or use at max 22 characters as the above examples show valid sheet names.
Or even better find out why some "codeName"s are ok and others not.

Created Unassigned: Sumifs calc issues [15548]

$
0
0
The sumifs formula gives the incorrect result in two instances:
* There are gaps in the range to be summed
* There are non-numeric cells in the range to be summed

In both instances the sequence to be summed becomes a different length to the criteria. This can result in correct results.

Created Unassigned: Comments.Remove on a cell breaks comments in same column [15549]

$
0
0
Version: EPPlus 4.1

After removing a comment from a cell, further accesses to comments on other cells of the same column get unexpected results: either cell.Comment returns null even if a comment is actually present, or ws.Comments.Remove(cell.Comment) throws "Comment does not exist in the worksheet" exception.

Unit tests for bug reproduction (using attached in.xslx):

```
[TestMethod]
public void BugCommentNullAfterRemove() {

string xls = "in.xlsx";

ExcelPackage theExcel = new ExcelPackage(new FileInfo(xls), true);

ExcelRangeBase cell;
ExcelComment cmnt;
ExcelWorksheet ws = theExcel.Workbook.Worksheets[1];

foreach (string addr in "B4 B11".Split(' ')) {
cell = ws.Cells[addr];
cmnt = cell.Comment;

Assert.IsNotNull(cmnt, "Comment in " + addr + " expected not null ");
ws.Comments.Remove(cmnt);
}

}

[TestMethod]
public void BugCommentExceptionOnRemove() {

string xls = "in.xlsx";

ExcelPackage theExcel = new ExcelPackage(new FileInfo(xls), true);

ExcelRangeBase cell;
ExcelComment cmnt;
ExcelWorksheet ws = theExcel.Workbook.Worksheets[1];

foreach (string addr in "B4 B16".Split(' ')) {
cell = ws.Cells[addr];
cmnt = cell.Comment;

try {
ws.Comments.Remove(cmnt);
} catch (Exception ex) {
Assert.Fail("Exception while removing comment at " + addr + ": " + ex.Message);
}
}

}

```
After initial investigation, the problem seems to be in CellStore<T>.Delete, because the content of _commentsStore gets corrupted immediately after the first call to ExcelCommentCollection.Remove.

Same code referencing EPPlus 4.0.5 works fine.

Created Unassigned: InsertRow fails with "row cannot be less than 1" [15550]

$
0
0
I recently upgraded from 4.0.5 to 4.1.0 and noticed this error

The following code results in exception "row cannot be less than 1"

int xlRow = 18;
using (ExcelPackage xl = new ExcelPackage(pfReport, template))
{
var wb = xl.Workbook;
ExcelWorksheet sht = wb.Worksheets[1];
--> sht.InsertRow(xlRow, 1);
xl.Save();
}

Note that the template file contains text in cells below row 18

When rolling back to version 4.0.5 the code runs normally

Created Unassigned: A problem with a borderStyle [15551]

$
0
0
Hello,

I have a problem with a property of an ExcelRange's borderStyle. I just wanted to set border style all of cells.
```
ws.Cells.Style.Border.Top.Style = ExcelBorderStyle.Thin;
ws.Cells.Style.Border.Left.Style = ExcelBorderStyle.Thin;
ws.Cells.Style.Border.Right.Style = ExcelBorderStyle.Thin;
ws.Cells.Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
```
(ws is an ExcelWorksheet)
After running I get the following error message: __"Object reference does not point to an instance of an object"__

And the message of the exception (StackTrace):
```
" в OfficeOpenXml.Style.XmlAccess.ExcelBorderItemXml.Copy()\r\n в OfficeOpenXml.Style.XmlAccess.ExcelBorderXml.Copy()\r\n в OfficeOpenXml.Style.XmlAccess.ExcelXfs.GetIdBorder(eStyleClass styleClass, eStyleProperty styleProperty, Object value)\r\n в OfficeOpenXml.Style.XmlAccess.ExcelXfs.GetNewID(ExcelStyleCollection`1 xfsCol, StyleBase styleObject, eStyleClass styleClass, eStyleProperty styleProperty, Object value)\r\n в OfficeOpenXml.ExcelStyles.<>c__DisplayClass16_1.<SetStyleAddress>b__0(List`1 list, Int32 index, Int32 row, Int32 column, Object args)\r\n в CellStore`1.SetRangeValueSpecial(Int32 fromRow, Int32 fromColumn, Int32 toRow, Int32 toColumn, SetRangeValueDelegate Updater, Object Value)\r\n в OfficeOpenXml.ExcelStyles.SetStyleAddress(StyleBase sender, StyleChangeEventArgs e, ExcelAddressBase address, ExcelWorksheet ws, Dictionary`2& styleCashe)\r\n в OfficeOpenXml.ExcelStyles.PropertyChange(StyleBase sender, StyleChangeEventArgs e)\r\n ....."
```
I even tried like this:
```
ws.Cells[4,4].Style.Border.Top.Style = ExcelBorderStyle.Thin;
ws.Cells[4,4].Style.Border.Left.Style = ExcelBorderStyle.Thin;
ws.Cells[4,4].Style.Border.Right.Style = ExcelBorderStyle.Thin;
ws.Cells[4,4].Style.Border.Bottom.Style = ExcelBorderStyle.Thin;
```
the same problem.

Thank you

Created Unassigned: Combining Sheets with styles results in exceptions [15552]

$
0
0
I generate a excel file, and then add an existing sheet (easier formatting) from a separate excel file.

When saving I would get an error. Upon inspection, I noticed that it tried to get an item in __ExcelStyleCollection__ from _list that would not exist. For example it would try to get PositionID 425, while the collection _list only contained 65 items. I noticed that I could find the wanted item using the Xfid. This solved the issue for me. Below is my quick fix.

The version I used for this was downloaded today.

```
public T this[int PositionID]
{
get
{
if(PositionID > _list.Count)
{
System.Diagnostics.Debug.Write($"Searched: {PositionID}: ");
var result = _list.Cast<Style.XmlAccess.ExcelXfs>().Where(x => ((Style.XmlAccess.ExcelXfs)x).XfId == PositionID).ToList();
if (result[0] is T) {
PositionID = _list.IndexOf((T)(object)result[0]);
System.Diagnostics.Debug.WriteLine($"Found");
}
else System.Diagnostics.Debug.WriteLine($"ERROR");

}

return _list[PositionID];
}
}
```

I hope this will help you fix this.

Commented Unassigned: Adding VBA to a file can lead to a corrupted file (sheetPr) [15547]

$
0
0
When loading a file and then using this line:
```
package.Workbook.CreateVBAProject();
```
the file can get corrupted. This happens because <sheetPr codeName="" ...> is changed or set incorrectly.
I noticed that the "codeName" should be at max 22 chars long, but there are examples where longer names do work fine.
Examples:
```
<sheetPr codeName="This is a longer name abC" is ok and 25 characters long
<sheetPr codeName="1-This is a longer name a" is not ok and 25 characters long
<sheetPr codeName="1-This is a longer name" is not ok and 23 characters long
<sheetPr codeName="1-This is a longer nam" is ok and 22 characters long
```

Currently I have two workarounds which are not good.
1) Get "codeName" of all sheets, use the "CreateVBAProject" function and restore the "codeName"s
2) Use the "CreateVBAProject" function and trim the "codeName"s to 22 chars.

Best fix would be to not update the "codeName" if it exists or use at max 22 characters as the above examples show valid sheet names.
Or even better find out why some "codeName"s are ok and others not.
Comments: The temporary workaround is also producing issues. Using this workaround will result in having multiple workbook VBA modules. Open the VBA editor Alt+F11 and there will be two modules per sheet: one normal and one that is marked to be of type workbook.

Commented Unassigned: Adding VBA to a file can lead to a corrupted file (sheetPr) [15547]

$
0
0
When loading a file and then using this line:
```
package.Workbook.CreateVBAProject();
```
the file can get corrupted. This happens because <sheetPr codeName="" ...> is changed or set incorrectly.
I noticed that the "codeName" should be at max 22 chars long, but there are examples where longer names do work fine.
Examples:
```
<sheetPr codeName="This is a longer name abC" is ok and 25 characters long
<sheetPr codeName="1-This is a longer name a" is not ok and 25 characters long
<sheetPr codeName="1-This is a longer name" is not ok and 23 characters long
<sheetPr codeName="1-This is a longer nam" is ok and 22 characters long
```

Currently I have two workarounds which are not good.
1) Get "codeName" of all sheets, use the "CreateVBAProject" function and restore the "codeName"s
2) Use the "CreateVBAProject" function and trim the "codeName"s to 22 chars.

Best fix would be to not update the "codeName" if it exists or use at max 22 characters as the above examples show valid sheet names.
Or even better find out why some "codeName"s are ok and others not.
Comments: I found now a working workaround (this is not a fix and not that good): Create a Dictionary<ExcelWorksheet,string> and fill it. Next change all sheet names to have a maximum length of 22 characters. Now you can use "package.Workbook.CreateVBAProject();". Afterwards use the Dictionary to restore all sheet names.

Commented Unassigned: Problem with escaped strings in formulas [15553]

$
0
0
I'm having an issue with making a formula work, due to the fact that the formula string contains quotes.
```
=IF(OR(L2="";M2="");"";L2-M2)
```

But after creating that string in c#, this is the result I get in the created excel file:
```
=IF(OR(L2=\"\";M2=\"\");\"\";L2-M2)
```

Needless to say, the file will be corrupt.
Any ideas why this happens?

This is my code:
```
int atCol = ws.Dimension.End.Column + 1;

for (int i = 2; i<=ws.Dimension.End.Row; i++)
{
var cell1 = ws.Cells[i, atCol + 1].Address;
var cell2 = ws.Cells[i, atCol + 2].Address;
var formula = string.Format(@"=IF(OR({0}="""";{1}="""");"""";{0}-{1})", cell1, cell2);
ws.Cells[i, atCol].Formula = formula;
}
```
Comments: Hi, not sure if I totally understand your problem - in C# you should be able to create any string with combination of quotes using the \". But you should not have a leading = in your formula when you add a formula via EPPlus. /Mats
Viewing all 2262 articles
Browse latest View live


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