EPPlus changes capitals to lowercase on formulas accessing different sheets

Viewed 156

I'm having an issue with EPPlus in C#. I created a document and it works fine except for one part. I'm trying to create a formula that accesses data from a different sheet.

summarySheet.Cells["A2"].Formula = "$Details.B19";

I've also tried

summarySheet.Cells["A2"].Formula = "=$Details.B19";

The cell showed #Name? for the value. When I checked the formula, the capital letters had been reduced to lowercase letters:

=$details.b19

So the formula doesn't work. On every formula that I've tried using a formula that access a different sheet, I get the same result. However, the formulas stay capitalized for the cell info from the same sheet. I tried subtracting data from one sheet from data from the same sheet:

summarySheet.Cells["A2"].Formula = "=$Details.B19 - B20";

And I get:

=$details.b19 - B20

So the capitalization error only occurs when accessing cells from a different sheet.

I'm guessing that it's something I'm doing wrong. My experience with C# is limited to personal projects and I've only started messing with EPPlus. Thanks for looking and thanks in advance for any help that's given.

1 Answers

Use the following

summarySheet.Cells["A2"].Formula = string.Format("'{0}'!{1}", sourceSheet.Name, sourceSheet.Cells["B19"].Address);
Related