Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 12, 2013 3:08 PM
Hi All,
I have a bit of an odd question for you, with regards to document libraries.
Basically I need to create a column that displays the 'File Format' of a file based on its extension. i.e. .doc will display Word, .xls will display Excel etc.
Anyone know where I should start? I know how to display the extenstions within a column, but just not the corresponding word.
Any help is much appreciated,
Michael
All replies (4)
Monday, August 12, 2013 10:44 PM ✅Answered | 1 vote
I don't think it's possible to that with a calculated column because neither the type (icon) or the name (filename) columns is available for use in the calculation. You can, however, do this with a SharePoint Designer modified view. First create a custom public view and then open it for editing in Designer. Select the standard XsltListViewWebPart, insert a column in the table (which displays the columns from the library) and then, using the Data Source Details pane, drag either the File Type or the FileLeafRef.Suffix column into your new column. That will add the XSL to display the file extensions. All you have to do then is to give the column a name.
If you really want a column displaying "Word", "Excel" etc. instead of the actual file extensions then you'll need some additional XSL along the lines of
<xsl:choose><xsl:when test="<$thisNode/@File_x0020_Type> = 'docx'">Word</xsl:when><xsl:otherwise>unknown</xsl:otherwise></xsl:choose>
Tom
SharePoint Systems Officer, Capital Regional District, BC, Canada
Tuesday, August 13, 2013 9:25 AM ✅Answered
Hi Mike,
There's two ways to do this as best I can recall. A rough stub wiki on both approaches can be read here: -
These approaches boil down to: -
- Building an XSLT dataview on your web part within SharePoint Designer (original solution here)
- Make some changes to the display pattern in ONET.XML
Monday, August 12, 2013 5:11 PM
Hi Michael, there's a couple ways to accomplish your goal. You could add a calculated column and make the document/extension = the "word." Or, you could add content types so that would automatically be done when someone uploads a file.
cameron rautmann
Tuesday, August 13, 2013 6:54 AM
Thanks Tom and Cameron, I will give them both a try and let you know how I get on.
I never thought of either of those possibilites, so thanks again for the input.
Michael