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

Created Unassigned: EPPlus Formula value resulting in #VALUE! [15585]

$
0
0
I have an Excel file with a table `tblPhoneCodes` and with two columns `Country` and `Code`, and I have a cell B1 with List Data Validation pointing to the `Country` column

and a cell B2 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(G2:G5,MATCH(B1,F2:F5,0)-1,0,1,1)

and a cell B3 basically it displays the `Code` for the selected `Country`. Cell B3 uses the following formula

=OFFSET(PhoneCodes,MATCH(B1,Countries,0)-1,0,1,1)

and a cell B4 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(INDIRECT("tblPhoneCodes[#Headers]"),MATCH(B1,INDIRECT("tblPhoneCodes[Country]"),0),1,1,1)

Everything in Excel works as it should, but the issue is when I am reading the value of B2, B3 and B4 using EPPlus in C# I am getting `#VALUE!` instead of the actual Phone `Code`. I've tried `.Calculate()` from workbook, worksheet, to cell and tried to access the value is still the same. I've attached the logger and it turns up empty and there is no error logged in it.

C# Code

static void Main(string[] args)
{
var excelFile = new FileInfo(@"C:\Users\Ash\Desktop\Epplus.xlsx");
using (var package = new ExcelPackage(excelFile))
{
// Output from the logger will be written to the following file
var logfile = new FileInfo(@"C:\Users\Ash\Desktop\EpplusLogFile.txt");
// Attach the logger before the calculation is performed.
package.Workbook.FormulaParserManager.AttachLogger(logfile);
// Calculate - can also be executed on sheet- or range level.
package.Workbook.Calculate();

Console.WriteLine(String.Format("Country: \t\t\t{0}", package.Workbook.Worksheets[1].Cells["B1"].Value));
Console.WriteLine(String.Format("Phone Code - Direct Reference:\t{0}", package.Workbook.Worksheets[1].Cells["B2"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Name Ranges:\t{0}", package.Workbook.Worksheets[1].Cells["B3"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Table reference:\t{0}", package.Workbook.Worksheets[1].Cells["B4"].Value.ToString()));

// The following method removes any logger attached to the workbook.
package.Workbook.FormulaParserManager.DetachLogger();
}
}

Output:

Country: China
Phone Code - Direct Reference: #VALUE!
Phone Code - Name Ranges: #VALUE!
Phone Code - Table reference: #VALUE!


I am using MS Excel 2010, .NET 4.0, EPPlus 4.1.0, and Windows 10 64bit

Edited Unassigned: EPPlus Formula value resulting in #VALUE! [15585]

$
0
0
I am trying to retrieve the cell content from Excel using EPPlus and it returns `#VALUE!`

To reproduce the issue I have an Excel file with a named range `Countries` and `PhoneCodes` and another table `tblPhoneCodes` and with two columns `Country` and `Code`, both the named range and table have the same data, and I have a cell B1 with List Data Validation pointing to the `Country` column

and a cell B2 basically it displays the `Code` for the selected `Country`. Cell B2 uses the following formula

=OFFSET(G2:G5,MATCH(B1,F2:F5,0)-1,0,1,1)

and a cell B3 basically it displays the `Code` for the selected `Country`. Cell B3 uses the following formula

=OFFSET(PhoneCodes,MATCH(B1,Countries,0)-1,0,1,1)

and a cell B4 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(INDIRECT("tblPhoneCodes[#Headers]"),MATCH(B1,INDIRECT("tblPhoneCodes[Country]"),0),1,1,1)

Everything in Excel works as it should, but the issue is when I am reading the value of B2, B3 and B4 using EPPlus in C# I am getting `#VALUE!` instead of the actual Phone `Code`. I've tried `.Calculate()` from workbook, worksheet, to cell and tried to access the value is still the same. I've attached the logger and it turns up empty and there is no error logged in it.

C# Code

static void Main(string[] args)
{
var excelFile = new FileInfo(@"C:\Users\Ash\Desktop\Epplus.xlsx");
using (var package = new ExcelPackage(excelFile))
{
// Output from the logger will be written to the following file
var logfile = new FileInfo(@"C:\Users\Ash\Desktop\EpplusLogFile.txt");
// Attach the logger before the calculation is performed.
package.Workbook.FormulaParserManager.AttachLogger(logfile);
// Calculate - can also be executed on sheet- or range level.
package.Workbook.Calculate();

Console.WriteLine(String.Format("Country: \t\t\t{0}", package.Workbook.Worksheets[1].Cells["B1"].Value));
Console.WriteLine(String.Format("Phone Code - Direct Reference:\t{0}", package.Workbook.Worksheets[1].Cells["B2"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Name Ranges:\t{0}", package.Workbook.Worksheets[1].Cells["B3"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Table reference:\t{0}", package.Workbook.Worksheets[1].Cells["B4"].Value.ToString()));

// The following method removes any logger attached to the workbook.
package.Workbook.FormulaParserManager.DetachLogger();
}
}

Output:

Country: China
Phone Code - Direct Reference: #VALUE!
Phone Code - Name Ranges: #VALUE!
Phone Code - Table reference: #VALUE!


I am using MS Excel 2010, .NET 4.0, EPPlus 4.1.0, and Windows 10 64bit

Commented Unassigned: EPPlus Formula value resulting in #VALUE! [15585]

$
0
0
I am trying to retrieve the cell content from Excel using EPPlus and it returns `#VALUE!`

To reproduce the issue I have an Excel file with a named range `Countries` and `PhoneCodes` and another table `tblPhoneCodes` and with two columns `Country` and `Code`, both the named range and table have the same data, and I have a cell B1 with List Data Validation pointing to the `Country` column

and a cell B2 basically it displays the `Code` for the selected `Country`. Cell B2 uses the following formula

=OFFSET(G2:G5,MATCH(B1,F2:F5,0)-1,0,1,1)

and a cell B3 basically it displays the `Code` for the selected `Country`. Cell B3 uses the following formula

=OFFSET(PhoneCodes,MATCH(B1,Countries,0)-1,0,1,1)

and a cell B4 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(INDIRECT("tblPhoneCodes[#Headers]"),MATCH(B1,INDIRECT("tblPhoneCodes[Country]"),0),1,1,1)

Everything in Excel works as it should, but the issue is when I am reading the value of B2, B3 and B4 using EPPlus in C# I am getting `#VALUE!` instead of the actual Phone `Code`. I've tried `.Calculate()` from workbook, worksheet, to cell and tried to access the value is still the same. I've attached the logger and it turns up empty and there is no error logged in it.

C# Code

static void Main(string[] args)
{
var excelFile = new FileInfo(@"C:\Users\Ash\Desktop\Epplus.xlsx");
using (var package = new ExcelPackage(excelFile))
{
// Output from the logger will be written to the following file
var logfile = new FileInfo(@"C:\Users\Ash\Desktop\EpplusLogFile.txt");
// Attach the logger before the calculation is performed.
package.Workbook.FormulaParserManager.AttachLogger(logfile);
// Calculate - can also be executed on sheet- or range level.
package.Workbook.Calculate();

Console.WriteLine(String.Format("Country: \t\t\t{0}", package.Workbook.Worksheets[1].Cells["B1"].Value));
Console.WriteLine(String.Format("Phone Code - Direct Reference:\t{0}", package.Workbook.Worksheets[1].Cells["B2"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Name Ranges:\t{0}", package.Workbook.Worksheets[1].Cells["B3"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Table reference:\t{0}", package.Workbook.Worksheets[1].Cells["B4"].Value.ToString()));

// The following method removes any logger attached to the workbook.
package.Workbook.FormulaParserManager.DetachLogger();
}
}

Output:

Country: China
Phone Code - Direct Reference: #VALUE!
Phone Code - Name Ranges: #VALUE!
Phone Code - Table reference: #VALUE!


I am using MS Excel 2010, .NET 4.0, EPPlus 4.1.0, and Windows 10 64bit
Comments: Please see the [discussion](https://epplus.codeplex.com/discussions/661056)

Edited Unassigned: EPPlus Formula value resulting in #VALUE! [15585]

$
0
0
I am trying to retrieve the cell content from Excel using EPPlus and it returns `#VALUE!`

To reproduce the issue I have an Excel file with a named range `Countries` and `PhoneCodes` and another table `tblPhoneCodes` and with two columns `Country` and `Code`, both the named range and table have the same data, and I have a cell B1 with List Data Validation pointing to the `Country` column

and a cell B2 basically it displays the `Code` for the selected `Country`. Cell B2 uses the following formula

=OFFSET(G2:G5,MATCH(B1,F2:F5,0)-1,0,1,1)

and a cell B3 basically it displays the `Code` for the selected `Country`. Cell B3 uses the following formula

=OFFSET(PhoneCodes,MATCH(B1,Countries,0)-1,0,1,1)

and a cell B4 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(INDIRECT("tblPhoneCodes[#Headers]"),MATCH(B1,INDIRECT("tblPhoneCodes[Country]"),0),1,1,1)

Everything in Excel works as it should, but the issue is when I am reading the value of B2, B3 and B4 using EPPlus in C# I am getting `#VALUE!` instead of the actual Phone `Code`. I've tried `.Calculate()` from workbook, worksheet, to cell and tried to access the value is still the same. I've attached the logger and it turns up empty and there is no error logged in it.

C# Code

static void Main(string[] args)
{
var excelFile = new FileInfo(@"C:\Users\Ash\Desktop\Epplus.xlsx");
using (var package = new ExcelPackage(excelFile))
{
// Output from the logger will be written to the following file
var logfile = new FileInfo(@"C:\Users\Ash\Desktop\EpplusLogFile.txt");
// Attach the logger before the calculation is performed.
package.Workbook.FormulaParserManager.AttachLogger(logfile);
// Calculate - can also be executed on sheet- or range level.
package.Workbook.Calculate();

Console.WriteLine(String.Format("Country: \t\t\t{0}", package.Workbook.Worksheets[1].Cells["B1"].Value));
Console.WriteLine(String.Format("Phone Code - Direct Reference:\t{0}", package.Workbook.Worksheets[1].Cells["B2"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Name Ranges:\t{0}", package.Workbook.Worksheets[1].Cells["B3"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Table reference:\t{0}", package.Workbook.Worksheets[1].Cells["B4"].Value.ToString()));

// The following method removes any logger attached to the workbook.
package.Workbook.FormulaParserManager.DetachLogger();
}
}

Output:

Country: China
Phone Code - Direct Reference: #VALUE!
Phone Code - Name Ranges: #VALUE!
Phone Code - Table reference: #VALUE!


I am using MS Excel 2010, .NET 4.0, EPPlus 4.1.0, and Windows 10 64bit

UPDATE:

Weirdly, it works if you don't have the `package.Workbook.Calculate();` in it

Created Unassigned: Huge performance issues after referencing ValidationList and Cells [15586]

$
0
0
Hello EPPlus-Team,

I have to set validation list references for about 3800 Cells in one worksheet.
This causes huge performance problems in setting the reference and saving the package at the end.

Without setting the references, saving and writing don't even take more than a second

this is the code I'm using. (using EPPlus 4.1)

```
static void Main(string[] args)
{
string path = @"D:\temp\Demo.xlsx";
using (ExcelPackage package = new ExcelPackage(new FileInfo(path)))
{
int row = 1;
int col = 1;

ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("TestWorkSheet");

List<string> data = new List<string>()
{
"Entry1","Entry2","Entry3","Entry4"
};

ExcelRange range = worksheet.Cells[row, col, row + data.Count - 1, col];
//Add Validation List
worksheet.Names.Add("ValidationList", range);
for (int i = 0; i < data.Count; i++)
{
int currentRow = row + i;
worksheet.Cells[currentRow, col].Value = data[i];
worksheet.Row(currentRow).Hidden = true;
}

//Reference the ValidationList for each cell (3800 Cells)
for (int i = 1; i < 381; i++)
{
for (int j = 0; j < 10; j++)
{
IExcelDataValidationList valList = worksheet.DataValidations.AddListValidation(worksheet.Cells[6 + j, i].Address);
valList.Formula.ExcelFormula = "=ValidationList";
}
}
Stopwatch swSave = new Stopwatch();
swSave.Start();
//Save Package
package.Save();
swSave.Stop();
Console.WriteLine("Saving:[" + swSave.Elapsed + "]");
}
}
```

Calling
```
IExcelDataValidationList valList = worksheet.DataValidations.AddListValidation(worksheet.Cells[6 + j, i].Address);
valList.Formula.ExcelFormula = "=ValidationList";
```
3800 times makes a time difference of 30 seconds.

It would be great if you could take a look at this and fix this performance problem.

Best regards
Jonas

Edited Unassigned: Huge performance issues after referencing ValidationList and Cells [15586]

$
0
0
Hello EPPlus-Team,

I have to set validation list references for a lot of Cells (up to 8000) in one worksheet.
This causes huge performance problems in setting the reference and saving the package at the end.

Without setting the references, saving and writing don't even take more than a second

this is the code I'm using. (using EPPlus 4.1)

```
static void Main(string[] args)
{
string path = @"D:\temp\Demo.xlsx";
using (ExcelPackage package = new ExcelPackage(new FileInfo(path)))
{
int row = 1;
int col = 1;

ExcelWorksheet worksheet = package.Workbook.Worksheets.Add("TestWorkSheet");

List<string> data = new List<string>()
{
"Entry1","Entry2","Entry3","Entry4"
};

ExcelRange range = worksheet.Cells[row, col, row + data.Count - 1, col];
//Add Validation List
worksheet.Names.Add("ValidationList", range);
for (int i = 0; i < data.Count; i++)
{
int currentRow = row + i;
worksheet.Cells[currentRow, col].Value = data[i];
worksheet.Row(currentRow).Hidden = true;
}

//Reference the ValidationList for each cell (3800 Cells)
for (int i = 1; i < 381; i++)
{
for (int j = 0; j < 10; j++)
{
IExcelDataValidationList valList = worksheet.DataValidations.AddListValidation(worksheet.Cells[6 + j, i].Address);
valList.Formula.ExcelFormula = "=ValidationList";
}
}
Stopwatch swSave = new Stopwatch();
swSave.Start();
//Save Package
package.Save();
swSave.Stop();
Console.WriteLine("Saving:[" + swSave.Elapsed + "]");
}
}
```

For each call of
```
IExcelDataValidationList valList = worksheet.DataValidations.AddListValidation(worksheet.Cells[6 + j, i].Address);
valList.Formula.ExcelFormula = "=ValidationList";
```
the amount of time,which is needed by ExcelPackage.Save() stacks.
Calling it 3800 times makes a time difference of 30 seconds.

It would be great if you could take a look at this and fix this performance problem.

Best regards
Jonas

Commented Issue: ExcelPackage.SaveAs fails under circumstances. [14830]

$
0
0
The following test fails in the nuget 3.1.2 package and source version http://epplus.codeplex.com/SourceControl/changeset/301d4b8c18fc

The styles of the worksheet seem to be or get corrupted beyond recognition on the second Update(...).

```
using System.IO;
using NUnit.Framework;
using OfficeOpenXml;

namespace RoundTrippingBug
{
[TestFixture]
public class EPPSaveLoadTest
{
[Test]
public void can_save_sheet_twice()
{
Stream source = CreateSheet();
Stream copy1 = Update(source);
Stream copy2 = Update(copy1);
}

private Stream Update(Stream source)
{
source.Position = 0;
MemoryStream copy = new MemoryStream();
using (ExcelPackage package = new ExcelPackage(source))
{
// vv these 2 lines trigger the bug. vv
package.Workbook.Styles.UpdateXml();
package.SaveAs(copy);
// ^^ these 2 lines trigger the bug. ^^
}
return copy;
}

private Stream CreateSheet()
{
MemoryStream stream = new MemoryStream();
using (ExcelPackage package = new ExcelPackage(stream))
{
ExcelWorksheet sheet = package.Workbook.Worksheets.Add("NewSheet1");
for (int row = 1; row < 10; row++)
for (int col = 1; col < 10; col++)
sheet.Cells[row, col].Value = string.Format("X{0},Y{1}", row, col);

package.Save();
}
return stream;
}
}
}
```
Comments: This issue is tested and works with version 4.1.0.0

Created Unassigned: v4.1.0 image (drawing) re-size causes wrong size, especially Jananese Excel file. [15587]

$
0
0
Excel calculates drawings size and offset in EMU, that has 9525 times precision of pixel.
But, EPPlus calculates drawings size in pixel.
This causes in wrong size (and aspect ratio) for small drawings at re-size.

(my customer has strict corporate logo usage guideline, wrong aspect ratio will violate them.)

Very confusing situation is row/column size calculation method.
They must be calculated in pixel, because historical reason (to speed up excel display). (EPPlus implements correctly this)

And more complex issue is here...
I'm live in japan, and japanese xlsx file has japanese font in default theme.
So excel use the font for column size calculation, but EPPlus has no japanese font information, then column calculation result in wrong size.

I attach the xlsx files and test code for test.


```
var template = new FileInfo(@"c:\temp\bug\resize-image.xlsx");
var image = new FileInfo(@"c:\temp\bug\test_logo.png");
const string output = @"c:\temp\bug\resize-image-Save.xlsx";

int row1, column1, roff1, coff1;
int row2, column2, roff2, coff2;

using (var pck = new ExcelPackage(template, false))
{
var ws = pck.Workbook.Worksheets[1];

var pic = ws.Drawings["image1"];
pic.SetSize(200);
row1 = pic.To.Row;
column1 = pic.To.Column;
roff1 = pic.To.RowOff;
coff1 = pic.To.ColumnOff;

pic = ws.Drawings.AddPicture("image2", image);
pic.SetPosition(3, 10, 3, 10);
pic.SetSize(75);

row2 = pic.To.Row;
column2 = pic.To.Column;
roff2 = pic.To.RowOff;
coff2 = pic.To.ColumnOff;

pck.SaveAs(new FileInfo(output));
}

using (var pck = new ExcelPackage(new FileInfo(output), false))
{
var ws = pck.Workbook.Worksheets[1];

var pic = ws.Drawings["image1"];
Assert.AreEqual(row1, pic.To.Row);
Assert.AreEqual(column1, pic.To.Column);
Assert.AreEqual(roff1, pic.To.RowOff);
Assert.AreEqual(coff1, pic.To.ColumnOff);

pic = ws.Drawings["image2"];
Assert.AreEqual(row2, pic.To.Row);
Assert.AreEqual(column2, pic.To.Column);
Assert.AreEqual(roff2, pic.To.RowOff);
Assert.AreEqual(coff2, pic.To.ColumnOff);

pck.SaveAs(new FileInfo(output));
}
```

Commented Unassigned: EPPlus Breaks Table Formulas [15538]

$
0
0
I have an xlsx file with two worksheets. The first worksheet has a table that is populated by the second worksheet. With just opening it as an EPPlus package and saving the package, the table is broken and each field in a column references the same cell. Looking at the underlying xml files, it appears that worksheet1.xml has the bad formulas associated with it, while table1.xml has the correct ones.

For example, column A, row 1 is ='Sheet2'!A1 and column A, row 2 = 'Sheet2'A2. After opening and saving it in EPPlus, we then have both cells in column A are ='Sheet2'A2. I have attached a before and after of the workbook. The C# code is below:

```
namespace WorkbookManager
{
class Program
{
static void Main(string[] args)
{
var options = new Options();
if (Parser.Default.ParseArguments(args, options))
{
var file = new FileInfo(@"C:\Temp\TableIssue-BeforeEPPlus.xlsx");

using (var excelPackage = new ExcelPackage(file))
{
excelPackage.SaveAs(new FileInfo(@"C:\tmp\TableIssue-AfterEPPlus.xlsx"));
}
}
}
}
}

```
Comments: We are experiencing the same issue. Are there any workarounds other than not using table formulas?

Created Unassigned: Spaces not allowed in TableName [15588]

$
0
0
In the file ExcelTableCollection.cs it says that spaces in table names are not allowed:

private void ValidateTableName(string Name)
{
if (string.IsNullOrEmpty(Name))
{
throw new ArgumentException("Tablename is null or empty");
}

char firstLetterOfName = Name[0];
if (Char.IsLetter(firstLetterOfName) == false && firstLetterOfName != '_' && firstLetterOfName != '\\')
{
throw new ArgumentException("Tablename start with invalid character");
}

if (Name.Contains(" "))
{
throw new ArgumentException("Tablename has spaces");
}

}

In the previous version this wasn't a problem, but now it became an Exception, Is there a specific reason for this?

Commented Unassigned: Spaces not allowed in TableName [15588]

$
0
0
In the file ExcelTableCollection.cs it says that spaces in table names are not allowed:

private void ValidateTableName(string Name)
{
if (string.IsNullOrEmpty(Name))
{
throw new ArgumentException("Tablename is null or empty");
}

char firstLetterOfName = Name[0];
if (Char.IsLetter(firstLetterOfName) == false && firstLetterOfName != '_' && firstLetterOfName != '\\')
{
throw new ArgumentException("Tablename start with invalid character");
}

if (Name.Contains(" "))
{
throw new ArgumentException("Tablename has spaces");
}

}

In the previous version this wasn't a problem, but now it became an Exception, Is there a specific reason for this?
Comments: Excel simply does not allow ListObjects with whitespaces in the name. You can check that by yourself by trying to add some whitespace to a table name. You will be greeted by a nice little error message that tells you its not allowed (this behavior exists since ListObjects were implemented in Excel as far as I remember).

Edited Unassigned: EPPlus Formula value resulting in #VALUE! [15585]

$
0
0
I am trying to retrieve the cell content from Excel using EPPlus and it returns `#VALUE!`

To reproduce the issue I have an Excel file with a named range `Countries` and `PhoneCodes` and another table `tblPhoneCodes` and with two columns `Country` and `Code`, both the named range and table have the same data, and I have a cell B1 with List Data Validation pointing to the `Country` column

and a cell B2 basically it displays the `Code` for the selected `Country`. Cell B2 uses the following formula

=OFFSET(G2:G5,MATCH(B1,F2:F5,0)-1,0,1,1)

and a cell B3 basically it displays the `Code` for the selected `Country`. Cell B3 uses the following formula

=OFFSET(PhoneCodes,MATCH(B1,Countries,0)-1,0,1,1)

and a cell B4 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(INDIRECT("tblPhoneCodes[#Headers]"),MATCH(B1,INDIRECT("tblPhoneCodes[Country]"),0),1,1,1)

Everything in Excel works as it should, but the issue is when I am reading the value of B2, B3 and B4 using EPPlus in C# I am getting `#VALUE!` instead of the actual Phone `Code`. I've tried `.Calculate()` from workbook, worksheet, to cell and tried to access the value is still the same. I've attached the logger and it turns up empty and there is no error logged in it.

C# Code

static void Main(string[] args)
{
var excelFile = new FileInfo(@"C:\Users\Ash\Desktop\Epplus.xlsx");
using (var package = new ExcelPackage(excelFile))
{
// Output from the logger will be written to the following file
var logfile = new FileInfo(@"C:\Users\Ash\Desktop\EpplusLogFile.txt");
// Attach the logger before the calculation is performed.
package.Workbook.FormulaParserManager.AttachLogger(logfile);
// Calculate - can also be executed on sheet- or range level.
package.Workbook.Calculate();

Console.WriteLine(String.Format("Country: \t\t\t{0}", package.Workbook.Worksheets[1].Cells["B1"].Value));
Console.WriteLine(String.Format("Phone Code - Direct Reference:\t{0}", package.Workbook.Worksheets[1].Cells["B2"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Name Ranges:\t{0}", package.Workbook.Worksheets[1].Cells["B3"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Table reference:\t{0}", package.Workbook.Worksheets[1].Cells["B4"].Value.ToString()));

// The following method removes any logger attached to the workbook.
package.Workbook.FormulaParserManager.DetachLogger();
}
}

Output:

Country: China
Phone Code - Direct Reference: #VALUE!
Phone Code - Name Ranges: #VALUE!
Phone Code - Table reference: #VALUE!


I am using MS Excel 2010, .NET 4.0, EPPlus 4.1.0, and Windows 10 64bit

UPDATE:

Weirdly, it works if you don't have the `package.Workbook.Calculate();` in it

Commented Unassigned: EPPlus Formula value resulting in #VALUE! [15585]

$
0
0
I am trying to retrieve the cell content from Excel using EPPlus and it returns `#VALUE!`

To reproduce the issue I have an Excel file with a named range `Countries` and `PhoneCodes` and another table `tblPhoneCodes` and with two columns `Country` and `Code`, both the named range and table have the same data, and I have a cell B1 with List Data Validation pointing to the `Country` column

and a cell B2 basically it displays the `Code` for the selected `Country`. Cell B2 uses the following formula

=OFFSET(G2:G5,MATCH(B1,F2:F5,0)-1,0,1,1)

and a cell B3 basically it displays the `Code` for the selected `Country`. Cell B3 uses the following formula

=OFFSET(PhoneCodes,MATCH(B1,Countries,0)-1,0,1,1)

and a cell B4 basically it displays the `Code` for the selected `Country`. Cell B4 uses the following formula

=OFFSET(INDIRECT("tblPhoneCodes[#Headers]"),MATCH(B1,INDIRECT("tblPhoneCodes[Country]"),0),1,1,1)

Everything in Excel works as it should, but the issue is when I am reading the value of B2, B3 and B4 using EPPlus in C# I am getting `#VALUE!` instead of the actual Phone `Code`. I've tried `.Calculate()` from workbook, worksheet, to cell and tried to access the value is still the same. I've attached the logger and it turns up empty and there is no error logged in it.

C# Code

static void Main(string[] args)
{
var excelFile = new FileInfo(@"C:\Users\Ash\Desktop\Epplus.xlsx");
using (var package = new ExcelPackage(excelFile))
{
// Output from the logger will be written to the following file
var logfile = new FileInfo(@"C:\Users\Ash\Desktop\EpplusLogFile.txt");
// Attach the logger before the calculation is performed.
package.Workbook.FormulaParserManager.AttachLogger(logfile);
// Calculate - can also be executed on sheet- or range level.
package.Workbook.Calculate();

Console.WriteLine(String.Format("Country: \t\t\t{0}", package.Workbook.Worksheets[1].Cells["B1"].Value));
Console.WriteLine(String.Format("Phone Code - Direct Reference:\t{0}", package.Workbook.Worksheets[1].Cells["B2"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Name Ranges:\t{0}", package.Workbook.Worksheets[1].Cells["B3"].Value.ToString()));
Console.WriteLine(String.Format("Phone Code - Table reference:\t{0}", package.Workbook.Worksheets[1].Cells["B4"].Value.ToString()));

// The following method removes any logger attached to the workbook.
package.Workbook.FormulaParserManager.DetachLogger();
}
}

Output:

Country: China
Phone Code - Direct Reference: #VALUE!
Phone Code - Name Ranges: #VALUE!
Phone Code - Table reference: #VALUE!


I am using MS Excel 2010, .NET 4.0, EPPlus 4.1.0, and Windows 10 64bit

UPDATE:

Weirdly, it works if you don't have the `package.Workbook.Calculate();` in it
Comments: Fixed in changeset 6cf0e60fbc63

Commented Unassigned: Spaces not allowed in TableName [15588]

$
0
0
In the file ExcelTableCollection.cs it says that spaces in table names are not allowed:

private void ValidateTableName(string Name)
{
if (string.IsNullOrEmpty(Name))
{
throw new ArgumentException("Tablename is null or empty");
}

char firstLetterOfName = Name[0];
if (Char.IsLetter(firstLetterOfName) == false && firstLetterOfName != '_' && firstLetterOfName != '\\')
{
throw new ArgumentException("Tablename start with invalid character");
}

if (Name.Contains(" "))
{
throw new ArgumentException("Tablename has spaces");
}

}

In the previous version this wasn't a problem, but now it became an Exception, Is there a specific reason for this?
Comments: Thanks for the feedback, that wasn't clear to me. Good to know, we can close this ticket then.

Created Unassigned: There was a problem sending the command to the program. [15589]

$
0
0
when I save excel file and try to open it with excel 2016 I get the following error:
"There was a problem sending the command to the program."
and excel opens up in compatibility mode. this does not happen in earlier versions of excel.
attached is the file produced, and here is source code:

```
_ public void GenerateExcelReport(DataTable dtSource, string reportName) {
foreach (DataColumn column in dtSource.Columns) {
column.ColumnName = PageUtil.FromCamelCase(column.ColumnName);
}

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
HttpContext.Current.Response.AddHeader("content-disposition", $"attachment;filename={reportName}.xlsx");

using (var excelPackage = new ExcelPackage()) {
// add worksheet
var workSheet = excelPackage.Workbook.Worksheets.Add(reportName);
workSheet.Cells["A1"].LoadFromDataTable(dtSource, true);

// make header BOLD
var totalCols = workSheet.Dimension.End.Column;
var headerCells = workSheet.Cells[1, 1, 1, totalCols];
headerCells.Style.Font.Bold = true;

var memoryStream = new System.IO.MemoryStream();
excelPackage.SaveAs(memoryStream);
memoryStream.WriteTo(HttpContext.Current.Response.OutputStream);
}

HttpContext.Current.Response.AddHeader("content-disposition", $"attachment;filename={reportName}.xlsx");

HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}_
```

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: Are there any plans or a PR open to try and get this unofficial port merged?

Commented Issue: Strange file error using package.Workbook.Worksheets[i].Hidden [12851]

$
0
0
First of all, i think the problem is in excel reading the file, but i have to detail a little.
I use this great library to open xlsx file from asp.net, add data and stream the file to the client with no update on disk; works like a charm except...
In some cases i have to hide a sheet depending on user selection and i used package.Workbook.Worksheets[1].Hidden = eWorkSheetHidden.Hidden or VeryHidden.
If i send the file with a sheet Hidden and open it, Excel show it but as i print preview the application crashes.
If instead of print preview i save the file to desktop, close excel and re-open it again and print preview, 90% cases no error.

Luckily (for me) i can delete the sheet instead of hiding, so i bypass the problem; however i wanted to detail it.

thanks,
Fabrizio
Comments: I am also getting this error using EPPlus 4.1.0. Has a solution/workaround been implemented? My code (VB.Net 2015): ``` Dim tblData As DataTable = New DataTable tblData.Columns.Add("Test1") tblData.Columns.Add("Test2") tblData.Columns.Add("Test3") tblData.Rows.Add("1", "2", "3") tblData.Rows.Add("2", "3", "4") tblData.Rows.Add("3", "4", "5") ' Create the excel document Dim epContainer As New OfficeOpenXml.ExcelPackage epContainer.Workbook.CreateVBAProject() ' Create the hidden worksheet Dim wsPivot = epContainer.Workbook.Worksheets.Add("Hidden") wsPivot.Hidden = OfficeOpenXml.eWorkSheetHidden.VeryHidden ' Create the data worksheet Dim epWorksheet As OfficeOpenXml.ExcelWorksheet = epContainer.Workbook.Worksheets.Add("Table") Dim datarange = epWorksheet.Cells("A1").LoadFromDataTable(tblData, True, OfficeOpenXml.Table.TableStyles.Light15) epWorksheet.Cells(epWorksheet.Dimension.Address).AutoFitColumns() epWorksheet.Select() Dim sFileName As String = "C:\Users\Public\Test.xlsm" If File.Exists(sFileName) = True Then File.Delete(sFileName) End If Using sStream As System.IO.FileStream = New System.IO.FileStream(sFileName, FileMode.CreateNew) epContainer.SaveAs(sStream) End Using ```

Created Unassigned: copying font from one cell to another doesn't function [15590]

$
0
0
I want to copy the style from one cell to another.

My code:
_ws.Cells[rowTarget, icol].Style.Font = _ws.Cells[rowSource, icol].Style.Font;
_ws.Cells[rowTarget, icol].Style.Fill = _ws.Cells[rowSource, icol].Style.Fill;
_ws.Cells[rowTarget, icol].Style.Border = _ws.Cells[rowSource, icol].Style.Border;
_ws.Cells[rowTarget, icol].Style.HorizontalAlignment = _ws.Cells[rowSource, icol].Style.HorizontalAlignment;
_ws.Cells[rowTarget, icol].Style.Indent = _ws.Cells[rowSource, icol].Style.Indent;
_ws.Cells[rowTarget, icol].Style.Numberformat = _ws.Cells[rowSource, icol].Style.Numberformat;
_ws.Cells[rowTarget, icol].Style.TextRotation = _ws.Cells[rowSource, icol].Style.TextRotation;
_ws.Cells[rowTarget, icol].Style.VerticalAlignment = _ws.Cells[rowSource, icol].Style.VerticalAlignment;
_ws.Cells[rowTarget, icol].Style.WrapText = _ws.Cells[rowSource, icol].Style.WrapText;

After executing
_ws.Cells[rowTarget, icol].Style.Font = _ws.Cells[rowSource, icol].Style.Font;

I notice that the font hasn't changed.
_ws.Cells[rowSource, icol] has been formatted using Excel. The file is an xlsx file.

I have tried to copy the style using StyleId or StyleName, neither work.



Created Unassigned: Increasing Comment Box Height and Width [15591]

$
0
0
I am using EP Plus in my project but comment box size is small to display. Please guide me how to increase height and width of the comment box.

Commented Unassigned: VLOOKUP returns #N/A [15442]

$
0
0
Hi team.

I have a problem in using "VLOOKUP".

When inputing data directly using Excel, I get the correct value.
But I can't get the correct value from my program.The return value will be "#N/A".

--- from ---
var inputExcelFile = new FileInfo("book1.xlsx");
using (var inputFile = new ExcelPackage(inputExcelFile))
{
var sheet = inputFile.Workbook.Worksheets["Sheet1"];

sheet.Cells["B3"].Value = "ABC_123";
sheet.Calculate("C3");

var value = sheet.Cells["C3"].Value;
}
--- to ---

I debuged a little bit and got why "#N/A" is returned.

If the "table_array" doesn't contain "RichText", I get the correct value.
But, if the "table_array" value in VLOOKUP function has "RichText" (for example, partially set the font to bold), the matching with the lookup_value will be matched with "RichText" and match will be FALSE.

Is my usage is incorrect?
Could anyone help me?

I'll attach a sample file.

# I'm japanese.Sorry for my bad English.

Comments: I have noticed same issue of Vlookup returns N/A. it is working properly without the "Calculate" Method. and returning the correct value.__ When using the "Calculate" the error appears in case VLookup formula contained only one 3 params. When i added the 4th param (RANGE_LOOKUP) for exact match (0) - it worked fine. is it a bug ?
Viewing all 2262 articles
Browse latest View live


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