We have a team site in our solution (SPS 2010 - Enterprise). On this site there's a list. For every new item in the list, it creates a new site from a template.


  • team-website
    • website 1
    • website 2
    • ...

On the template for these sites there is (among other elements) a document library with a single Excel file (.xlsx) and a Chart Web Part. The data source of the Chart Web Part is the Excel file (using Excel Services).

The source for the web part can be set 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 web part.

A logical solution for me was to add a new web part to my Visual Studio project, that derives from ChartWebPart. I checked MSDN and found the WorkBookUrl member and overrode 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 site as a template. From this template I created a site and... no Chart Web Part. (It is definitely there, since the debugger jumps in on the breakpoint 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 work in the end or it's something else. I tried some other things too, like editing the DataBindingString, nothing worked.

EDIT: I tried using a list instead, and it worked fine. That still doesn't answer my question of why it doesn't work with the WorkBookUrl though.

  • If you add ?Contents=1 to your page URL, does the web part in question show as Closed? rlr
    – rlramirez
    Commented Jun 22, 2011 at 19:09

1 Answer 1


If you add the default chart webpart, set the properties (url), mark it as exportable and then export the webpart, you get a .webpart file.

Can you try and include this exported webpart (with a relative url in it, so edit the .webpart file first) in another site. Go to a new site, edit page, then in the webpart ribbon underneath the categories you have an upload link. Upload the (edited) .webpart file.

If this works, you can include this webpart in a page by default (in for instance a site definition or webtemplate) using the AllUserWebPart XML Element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.