Last time one of my Clients asked me for a possibility to extend document libraries with Excel template. The choice was obvious – a custom content type with Excel document template. I have created such a content type in few minutes, created a package, run deployment process and… Voilà! Site content type has been created.

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
 <!-- Parent ContentType: Document (0x0101) -->
 <ContentType ID="0x0101007854B51762FA4A7C92E8568CE37E5A5C"
 Group="Document Templates"
 <DocumentTemplate TargetName="Excel.xltx"></DocumentTemplate>
 <Module Name="ExcelTemplate" Url="_cts/Excel">
 <File Type="Ghostable" Url="Excel.xltx" Path="Excel/Excel.xltx"></File>

To make some tests, I have added it to a document library and created a new document. At this point everything seemed to be OK.


After a few clicks I noticed that content type of my newly created Excel file was set to Document instead of Excel.



I double checked content types’ xml definition, any errors during deployment process, but I did not found anything special. Some time later I noticed, that when I reassign the document type from the UI, content type starts working properly. Thanks to that I came up with a simple solution – I added a feature receiver in which I reassing the document template:

public override void FeatureActivated(SPFeatureReceiverProperties properties)
SPSite site = properties.Feature.Parent as SPSite;
SPContentType ctExcel = site.RootWeb.ContentTypes["Excel"];
ctExcel.DocumentTemplate = ctExcel.DocumentTemplate;

That fixed the problem!