Assign WSS Document Parser to specific Extension

December 30, 2007

The other day I was working with some excel documents within SharePoint 3.0 and I’ve noticed the excel template files do OLE properties do not get promoted into SPListItem properties. After some digging around I’ve found that the excel template extension *.XLT is not assigned to the default SharePoint office document parser.

The solution was somewhat harder to find, but finally I found this on the net:

SPFarm farm = SPFarm.Local;

SPWebService service = farm.Services.GetValue<SPWebService>();

SPDocumentParser customParser = new SPDocumentParser(“SharePoint.SPDocumentParser.OfficeParser”, “xlt”);

service.PluggableParsers.Add(“xlt”, customParser);

service.Update();

The *.XLT extension assignmentto the OfficParser is done at farm level. After running this code, all excel template files uploaded to SharePoint get their OLE properties promoted into SPListItem properties bag, as described in the WSS SDK custom document parsers section.

This solved the *.XLT problem, but shortly another one was revealed: the OfficeParser seems to promote only string type OLE properties, and OLE fields with float and DateTime types are ignored. I hope to get back to this problem when I’ll know more.