Actually, this is a bit misleading. Named ranges are stored at the workBOOK level, not the workSHEET level. Therefore, if you do something like this:
[TestMethod] public void Get_Named_Range_Test() { //http://stackoverflow.com/questions/30494913/is-there-a-way-to-get-named-cells-using-epplus var existingFile = new FileInfo(@"c:\temp\NamedRange.xlsx"); using (var pck = new ExcelPackage(existingFile)) { var wb = pck.Workbook; //Not workSHEET var namedCell1 = wb.Names["namedCell1"]; Console.WriteLine("{{\"before\": {0}}}", namedCell1.Value); namedCell1.Value = "abc123"; Console.WriteLine("{{\"after\": {0}}}", namedCell1.Value); } }
You get this in the output (using an excel file with dummy data in it):
{"before": Range1 B2} {"after": abc123}
Ernie
source share