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

Edited Unassigned: The same local name in two different worksheets [15386]

$
0
0
I use local name ranges for calculations (i.e. their scope is only within a particular sheet), rather than global named ranges, which apply to an entire workbook. If I have two sheets in a workbook with the same local named range in them, I've noticed that there seems to be a bug.

E.g. I have a range "ClientName" in both Sheet1 and Sheet2 of workbook "Book1". I can read from and write to both names and it seems to work fine. But the property "Worksheet" on the names will both be "Sheet1".

Where this breaks is when I try to copy the entirety of Sheet2 into a different workbook, "Book2". The CopySheetNames() private method in ExcelWorksheets freaks out over the reference to a Worksheet that doesn't exist in Book2, so a null reference exception gets thrown.

I think the issue needs to be traced back to when the ExcelNamedRanges are constructed in the first place. I haven't had a go at fixing it myself in case it's already on your radar, but I'm happy to dig in if it's not.

EDIT - Sorry, user error. Ignore this. How do I delete it?

Commented Unassigned: Formulas within existing rows are corrupted when a new row is added [15339]

$
0
0
Formulas within existing rows are corrupted when a new row is added. Formulas that reference another worksheet within the same workbook are corrupted when a new row is inserted. The error is occurring in method 'ExcelCellBase.UpdateFormulaReferences'. This method is attempting to adjust addresses that might have shifted as a result of the newly inserted row. The method currently fails to check whether the addresses within the formula refer to another worksheet. As a result, the method attempts to adjust the formula address when it should not do so, and thereby corrupts the formula.

We have circumvented the problem by updating the 'UpdateFormulaReferences' method to check whether the address within the formula refers to another worksheet before adjusting the address. In file ExcelCellBase.cs at line 859, we added the 'if (!String.IsNullOrEmpty' statement below.

```
foreach (var t in tokens)
{
if (t.TokenType == TokenType.ExcelAddress)
{
var a = new ExcelAddressBase(t.Value);

if (!String.IsNullOrEmpty(a._ws))
{
// This address is in a different worksheet, thus no update is required
f += a.Address;
continue;
}
__```

The attached example sheet illustrates the problem. The first worksheet contains an integer value in the first column and a 'VLOOKUP' formula in the second column that refers to a lookup table on the second worksheet. The integer value in the first column is the argument to the VLOOKUP formula. The first worksheet contains three data rows. You can reproduce the problem by inserting a new row near the top of the worksheet. You will observe that the formulas in all of the existing rows are corrupted following the insert.
Comments: This should be extended by: ``` if ( !String.IsNullOrEmpty(a._wb) || !String.IsNullOrEmpty(a._ws) ) ``` So references to other workbooks are not updated aswell.

Edited Unassigned: IGNORE - The same local name in two different worksheets [15386]

$
0
0
I use local name ranges for calculations (i.e. their scope is only within a particular sheet), rather than global named ranges, which apply to an entire workbook. If I have two sheets in a workbook with the same local named range in them, I've noticed that there seems to be a bug.

E.g. I have a range "ClientName" in both Sheet1 and Sheet2 of workbook "Book1". I can read from and write to both names and it seems to work fine. But the property "Worksheet" on the names will both be "Sheet1".

Where this breaks is when I try to copy the entirety of Sheet2 into a different workbook, "Book2". The CopySheetNames() private method in ExcelWorksheets freaks out over the reference to a Worksheet that doesn't exist in Book2, so a null reference exception gets thrown.

I think the issue needs to be traced back to when the ExcelNamedRanges are constructed in the first place. I haven't had a go at fixing it myself in case it's already on your radar, but I'm happy to dig in if it's not.

EDIT - Sorry, user error. Ignore this. How do I delete it?

Commented Unassigned: Formulas within existing rows are corrupted when a new row is added [15339]

$
0
0
Formulas within existing rows are corrupted when a new row is added. Formulas that reference another worksheet within the same workbook are corrupted when a new row is inserted. The error is occurring in method 'ExcelCellBase.UpdateFormulaReferences'. This method is attempting to adjust addresses that might have shifted as a result of the newly inserted row. The method currently fails to check whether the addresses within the formula refer to another worksheet. As a result, the method attempts to adjust the formula address when it should not do so, and thereby corrupts the formula.

We have circumvented the problem by updating the 'UpdateFormulaReferences' method to check whether the address within the formula refers to another worksheet before adjusting the address. In file ExcelCellBase.cs at line 859, we added the 'if (!String.IsNullOrEmpty' statement below.

```
foreach (var t in tokens)
{
if (t.TokenType == TokenType.ExcelAddress)
{
var a = new ExcelAddressBase(t.Value);

if (!String.IsNullOrEmpty(a._ws))
{
// This address is in a different worksheet, thus no update is required
f += a.Address;
continue;
}
__```

The attached example sheet illustrates the problem. The first worksheet contains an integer value in the first column and a 'VLOOKUP' formula in the second column that refers to a lookup table on the second worksheet. The integer value in the first column is the argument to the VLOOKUP formula. The first worksheet contains three data rows. You can reproduce the problem by inserting a new row near the top of the worksheet. You will observe that the formulas in all of the existing rows are corrupted following the insert.
Comments: I found another issue inside "ExcelWorksheet.cs" at line 150 ``` var a = new ExcelFormulaAddress(token.Value); f += a.GetOffset(row - StartRow, column - StartCol); ``` should be ``` var a = new ExcelFormulaAddress(token.Value); if (!String.IsNullOrEmpty(a._wb) || !String.IsNullOrEmpty(a._ws)) { f += token.Value; } else { f += a.GetOffset(row - StartRow, column - StartCol); } ``` This is required when using "Calculate" function of ExcelRange. There could be even more locations inside the source that would need a change too.

Edited Unassigned: Copying a worksheet from xlsx to xlsm file [15386]

$
0
0
[NOTE I have repurposed my issue to report what I think is an actual EPPlus issue, rather than me being an idiot]

EPPlus throws an exception when I copy a worksheet from Book1.xlsx to Book2.xlsm.

I can fix the null reference exception in my copy of your code by only copying the VBA code across if Copy.CodeModule != null (around line 275 of ExcelWorksheets.cs).

Then the copy is successful, but named ranges are all broken in the resulting worksheet.

Edited Unassigned: Copying a worksheet from xlsx to xlsm file [15386]

$
0
0
EPPlus throws an exception when I copy a worksheet from Book1.xlsx to Book2.xlsm.

I can fix the null reference exception in my copy of your code by only copying the VBA code across if Copy.CodeModule != null (around line 275 of ExcelWorksheets.cs).

Then the copy is successful, but named ranges are all broken (i.e. have disappeared) in the resulting copied worksheet.

[NOTE I have repurposed my issue to report what I think is an actual EPPlus issue, rather than me being an idiot]

Created Unassigned: ExcelRow.Height sets wrong height to ALL drawings in v4.0.4 [15387]

$
0
0
I add some picture (Drawings) with EditAs = OneCell (default) and set size,
then change some row's height, after that, all drawing's heights are changed (changed value is equal to width size).

following is test code:
```
ExcelWorksheet worksheet = package.Workbook.Worksheets.First();
var _imagePath = outputDir.FullName + @"\image.jpg";
var _image = System.Drawing.Image.FromFile(_imagePath);

var picture = worksheet.Drawings.AddPicture("Image", _image);
picture.SetPosition(0, 0, 0, 0);
picture.SetSize(200, 40);
picture.Locked = true;
picture.EditAs = OfficeOpenXml.Drawing.eEditAs.Absolute;

Samplex.AddPicture(worksheet, "Image1", _image, 0, 0, 200, 40);
worksheet.Row(1).Height = 50;
```


In ExcelRow's Height property, there is suspicious code:
```
public double Height
{
...
set
{
var r = GetRowInternal();
if (_worksheet._package.DoAdjustDrawings)
{
var pos = _worksheet.Drawings.GetDrawingWidths();
r.Height = value;
_worksheet.Drawings.AdjustHeight(pos);
}
else
...
}
}
```
Is it not __GetDrawingWidths__ but __GetDrawingHeight__ ?
(I think this codes is based on ExcelColumn's Width property...)

Created Unassigned: ClosedXML files are empty [15388]

$
0
0
I'm using EPPlus to open an .xlsx file generated with ClosedXML library and unfortunately something gets wrong, since the file is opened as an empty worksheet with no data (rows and columns collections are empty).
The file has custom properties and I noticed that they're still present: I'm sorry to say that that they're the only "data" that is maintained when opening with EPPlus library... :(
Are you aware of any compatibilty issues between these two libraries?


Commented Unassigned: emails with excel files get filtered out EPPlus 4.0.4 [15278]

$
0
0
recently upgraded from 3.1.3.3 to 4.0.4. yesterday got a complaint from a client that emails with excel files attached, created by epplus were getting filtered out and removed in messages sent externally. the excel file was replaced with a text file, with the same name filename.xlsx.txt with one line "This attachment was removed.". doing some googling i found out that the exchange edge server was doing the filtering. I told my sys admin and he tried to ensure that xlsx files would not get filtered out by the edge server. he tried a bunch of settings and couldn't get it to work. finally this morning i remembered I had updated epplus to 4.0.4, so i reverted back to the old 3.1.3.3 and tried it and the excel file sends normally when going external.
So there must have been a change in the file signature in 4.0.4 that the edge server picks up as a virus and filters it out.
Comments: I have the same issue. How to fix the issue by workaround using version 4.0.4 ?

Created Unassigned: Remove DotNetZip from source [15389]

$
0
0
Why DotNetZip source is included ins source code of EPPlus?
I have OutOfMemoryException when exporting large amount of data. I've removed DotNetZip and replaced it with Nuget package. Now I can export half million rows per file.

EPPlus source should be as simple as possible. Besides is it maintained? Why not move source to GitHub, this way we all could easier fix issues and help making EPPlus even better!

Commented Unassigned: Copying a worksheet from xlsx to xlsm file [15386]

$
0
0
EPPlus throws an exception when I copy a worksheet from Book1.xlsx to Book2.xlsm.

I can fix the null reference exception in my copy of your code by only copying the VBA code across if Copy.CodeModule != null (around line 275 of ExcelWorksheets.cs).

Then the copy is successful, but named ranges are all broken (i.e. have disappeared) in the resulting copied worksheet.

[NOTE I have repurposed my issue to report what I think is an actual EPPlus issue, rather than me being an idiot]
Comments: This could be the same problem I'm having, though I'm not copying worksheets. https://epplus.codeplex.com/discussions/648558

Created Unassigned: ExcelPicture.SetPosition(int Row, int RowOffsetPixels, int Column, int ColumnOffsetPixels); should position top left, not bottom right [15390]

$
0
0
I have some trouble with this method:
```
ExcelPicture.SetPosition(int Row, int RowOffsetPixels, int Column, int ColumnOffsetPixel)
```
Code example
```
ExcelPackage pck = new ExcelPackage();
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Test");
ExcelPicture picture = ws.Drawings.AddPicture("", Image.FromFile(Path.GetFullPath("..\\..\\Clown-Tux-icon.png")));
picture.SetPosition(1, 0, 1, 0);
pck.File = new FileInfo(Path.GetFullPath("..\\..\\test.xlsx"));
pck.Save();
```
I expect the image to start from the top left point in cell A1, but it does not. The image is placed in B2 instead (or bottom right A1, not sure).
![Image](http://i.imgur.com/i2wNtno.png?1)

It almost looks like SetPosition use zero indexed rows and columns, while excel and epplus in general don't. Example:
```
ws.Cells[new ExcelAddress(1, 1, 1, 1).Address].Value = "This will show up in A1";
```


Created Unassigned: ExcelPicture.SetPosition(int Row, int RowOffsetPixels, int Column, int ColumnOffsetPixels) offset problem [15391]

$
0
0
If you add an image with too much negative offset, you get a unfortunate bug that only shows up if you change the excel document later on.

To reproduce, run this
```
ExcelPackage pck = new ExcelPackage();
ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Test");
ExcelPicture picture = ws.Drawings.AddPicture("", Image.FromFile(Path.GetFullPath("..\\..\\Clown-Tux-icon.png")));
picture.SetPosition(10, -100, 10, -100);
pck.File = new FileInfo(Path.GetFullPath("..\\..\\test.xlsx"));
pck.Save();
```
* Open document in excel
* Yay it works! or does it?
* Enter a number like 1 somewhere
* Save and close excel
* Open same document and an error appears

> We found a problem with some content in 'test.xlsx'. Do you want us to try recover as much as we can? If you trust the source of this workbook, click Yes
![Image](http://i.imgur.com/kuqOuMZ.png)


I think it would be better if this was detected earlier and gave me a runtime ArgumentException or similar if the offset was too negative. Do we need to allow negative offset at all?

Created Unassigned: Scatterchart line [15392]

$
0
0
Hi i created scatterchart excel from c# code.i got excel as needed.bt i need one help from you ,not connceted a points in graph.only show the points. for your reference here attached my excel sheet.

Created Unassigned: Try to open Worksheet ends in endless loop - bug in CreateXml? [15393]

$
0
0
Hi Colleagues,

I open several XLS with EPPPlus, all fine. But some lead to an endless loop while the file opens just fine in Excel.

I tried to nail down the issue, here is what I found:

//Excerpt from ExcelWorksheet.cs (latest v4.0.4)
CreateXML...

XmlTextReader xr = new XmlTextReader(stream);
xr.ProhibitDtd = true;
xr.WhitespaceHandling = WhitespaceHandling.None;
LoadColumns(xr); //columnXml
long start = stream.Position; __// Save start position of stream__
LoadCells(xr);
var nextElementLength = GetAttributeLength(xr);
long end = stream.Position - nextElementLength; __//Get End position of Stream
__
...
in my error case, start==end==4096.

According to .net info about XMLTextReader, it is buffered, thus using stream.Position does not have to work - which seems to be the case here.

As there doesn't seem to exist an easy (working) substitute for stream.Position, I can't fix on my own. Any ideas how this could be done?

(As the affected XLS is confidential, I can't upload it)

br, Christian




Created Unassigned: Update External Links Property needed [15394]

$
0
0
Hi EPPlus developers,

we need two properties of Excel Workbook: one to switch UpdateExternalLinks mode (__updateLinks__: always, never, userSet) and one to manage whether external Links data will be saved (__saveExternalLinkValues__: true/false)

As a tradition: I add my patch with the proposed solution. I tried to follow your developer style by adding the properties.

Created Unassigned: Issue saving complex string value [15395]

$
0
0
When I try to insert a DataTable using

```
sheet.Cells["A1"].LoadFromDataTable(data, true);
```

if the DataTable contains a string column containing large complex data, in my case a geometry GeoJson or KML string value, then the resulting Excel file requires Excel to repair it when opening. Excel provides the following message "Repaired Records: String properties from /xl/sharedStrings.xml part (Strings)".

Commented Unassigned: Issue saving complex string value [15395]

$
0
0
When I try to insert a DataTable using

```
sheet.Cells["A1"].LoadFromDataTable(data, true);
```

if the DataTable contains a string column containing large complex data, in my case a geometry GeoJson or KML string value, then the resulting Excel file requires Excel to repair it when opening. Excel provides the following message "Repaired Records: String properties from /xl/sharedStrings.xml part (Strings)".
Comments: This issue can be closed. Seems I'm trying to exceed limits imposed by Excel. I was trying to insert more than 32,767 characters in a cell. Limits are described here - https://support.office.com/en-MY/article/Excel-specifications-and-limits-16c69c74-3d6a-4aaf-ba35-e6eb276e8eaa

Commented Unassigned: EPPlus 4.0 RC. InsertRow not correct! [15090]

$
0
0
Function InsertRow(int,int, int ) does not work properly.
```

ExcelPackage p = new ExcelPackage(new FileInfo(@"C:\b.xlsx"), new FileInfo(@"C:\a.xlsx"));
ExcelWorksheet sheet = p.Workbook.Worksheets[1];
sheet.InsertRow(5, 10,4);
p.Save();
```

Out of line # 4, not all cells are copied!
Comments: This is still an issue in 4.0.4 as the 3 value passed in for copyStylesFromRow is used after the new rows are created. If you want to use the row that you started on for formatting: ``` sheet.InsertRow(4, 10, 4); ``` It will insert 10 rows then copy the new 4th row which has no formatting. To get the expected result, you would have to pass the 14 in as the copyStylesFromRow which isn't the expected behavior.

Created Unassigned: Version 4.0.4 produces OleDB unreadable workbook [15396]

$
0
0
Hi EPPlus team,
an issue with reading xlsx by OleDB reader was found since we have upgraded EPPlus library from 2.8.0.2 to 4.0.4.0.
In case of 4.0.4 output throws OleDbConnection.Open exception:
> "External table is not in the expected format."

although epp 2.8.0 prododuces OleDB compatible result. See following example for demonstration this behavior:

```C#
static void Main()
{
const string name = "Data";
const string ConnectionStringMask = "Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=\"Excel 12.0;ReadOnly=True;HDR=Yes;IMEX=1;TypeGuessRows=0\";Data Source={0}";

var data = new[]
{
new object[] {"AB", "1/1/2010"},
new object[] {"Test", 1.25}
};

var tmp = new FileInfo(Path.GetTempFileName());
if (tmp.Exists) tmp.Delete();
var file = new FileInfo(Path.ChangeExtension(tmp.FullName, ".xlsx"));
if (file.Exists) file.Delete();

using (var excel = new ExcelPackage(file))
{
var sheet = excel.Workbook.Worksheets.Add(name);
var range = sheet.Cells[2, 2].LoadFromArrays(data);
excel.Workbook.Names.Add(name, range);
excel.Save();
}

var constr = string.Format( ConnectionStringMask, file.FullName );
var dt = new DataTable();
using (var con = new OleDbConnection(constr))
{
con.Open();

var cmd = new OleDbCommand(string.Format("SELECT * FROM [{0}]", name), con);
var reader = cmd.ExecuteReader();
if (reader == null) throw new NoNullAllowedException();
dt.Load(reader);
}
}
```
> Both results ( 2.8.0, 4.0.4 ) are open in MS excel without warnings.
> After open and save in MS excel is content readable in OleDB.

Attached is xlsx produced by version 2.0.8

We need to open the xlsx via OleDb, could you help us with a workaround or fix?

Thank you
Viewing all 2262 articles
Browse latest View live


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