I'm using EPPlus to populate an excel file, I have many pivot tables that refresh when the file is opened.
Their source is always one of the two sheets populated by my application.
The problem is that everytime I populate there is a different number of rows, I tried using a named range in their source but when I change the range of the named range with EPPlus , it doesnt work.
epplusWs.Workbook.Names["named_range"].Address = "data_sheet!$A$1:$H$" + row.ToString();
This is a late answer but you could add a new named ranged like this:
ExcelNamedRange NR = new ExcelNamedRange("named_range", sheet: worksheet, nameSheet: worksheet, address: <your address string here>, index: 1);
package.Workbook.Worksheets[1].Names.Add("named_range", NR);
I find a way to edit an existing one :
var range = epplusWs.Workbook.Names[rangeName];
range.Address = "YourNewRange";
epplusWs.Workbook.Names.Remove(rangeName);
epplusWs.Workbook.Names.Add(rangeName, range);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With