We use an existing XLS-file as a template, which is dynamically updated through ASP.net.
In this template there is 1 worksheet with the data (Worksheets[0]), and several worksheets with Charts.
When we try to edit the existing Chart's name and DataRange, this does not work.
- Code: Select all
var workbook = new Workbook();
workbook.LoadFromFile(Page.MapPath(@"./Excel/Template.xls"), true);
var sheet = workbook.Worksheets[0];
chrt = workbook.Worksheets[1].Charts[0];
chrt.ChartTitle = "This is the new title";
chrt.DataRange = sheet.Range[string.Format("R4C1:R21C14"), true];
Setting the ChartTitle sometimes throws a null-reference exception.
Can anyone please assist? Thank you very much,
Frans-Willem Post
GSD Automatisering