First, sorry for this relatively simple and stupid question, but the ChartWebPart is probably the worst documented WebPart I've been working with so far. (Official and community side!)
I'll try to explain my situation. We have a team-website in our solution. (SPS 2010 - Enterprise) On this site there's a list. For every new item in the list, it creates a new website from a template. structure:
- team-website
- website 1
- website 2
- ...
on the template for these websites there is (among other elements) a document-list with a single excel-file (.xlsx) and a ChartWebPart. The datasource of the ChartWebPart is the excel-file. (using Excel Services) And there is the problem, you see:
The source for the WebPart can be set absolutely without much hassle and it works as it should. But, since the template is used for these various websites, this isn't a working solution and I haven't figured out a way to set the url relatively on the WP. (Or did I? > see below)
A logical solution for me was it to add a new web-part to my visual stutio Projekt, that derives from the ChartWebPart. I checked the msdn and found the WorkBookUrl-member which sounded promising to me. I overrid the OnInit() method:
protected override void OnInit(EventArgs e)
{
string excelFile = SPContext.Current.Web.ServerRelativeUrl
+ "/Dokumente/siteSheet.xlsx";
this.WorkBookUrl = excelFile;
}
Then I did a test, and it worked like a charm. After that, I made some last changes on the chart's design and saved the website as a template. From this templete I created a website and... no ChartWebPart. (It is defintely there, since the debugger jumps in on the break-point I set in the OnInit-method, but I can't see it!) I don't know what's the problem here. Either my code doesn't works in the end or it's something else. I tried some other things too, like editing the DataBindingString, nothing worked.
Please, can someone help me out? I'm seriously dying on this one
EDIT: I tried using a list instead, and it worked fine. That still doesn't answers my question, why it doesn't work with the WorkBookUrl though.