I was able to create a chart in Excel using WPF. I can apply Excel Excel layouts to a chart using:
xlChart.ApplyLayout(i);
Where xlChart is my chart, and "i" is the layout I choose.
However, I want to take a step further than this and apply my own custom chart type. I created a chart type in Excel and saved it as a crtx file. I added this to my project as an embedded resource and tried to apply it to an Excel chart as follows:
var file = new Uri("pack://application:,,,/Resources/Templates/line.crtx");
xlChart.ApplyChartTemplate(file.AbsoluteUri);
However, this does not occur with
HRESULT_FAIL
I'm probably incorrectly referencing the template, so hopefully someone out there can help!
Edit:
I managed to find a workaround. I can copy the template to the output directory and reference it using:
var path = Path.GetFullPath("Resources/Templates/line.crtx");
xlChart.ApplyChartTemplate(path);
, , . , !