Wednesday 17 April 2013

Survey questions are not exported in the right order when you select “export to spreadsheet” to Excel on Sharepoint 2010.

Surveys in Sharepoint 2010 are quite limited, but I have to admit this limitation brings simplicity to the users. Some users become quite confuse when it comes to InfoPath, so why not giving them the option of developing surveys?.

If one of them it is causing trouble and needs extra functionality, we can always add it, at the end of the day a Survey is a custom list.

There is bug in Sharepoint 2010 where the survey questions are not exported in the right order when you select “export to spreadsheet”. Why is this happening?, because a file called Overview.aspx as well as AllItems.aspx and summary.aspx have been build gradually in LILO (Last In Last Out) order. To fix this issue we only need to edit these files, and I will advise to modify only Overview.aspx. This file has the option to “export to spreadsheet”.

Step 1
Click on your survey, and you will end in a screen like this:
image

 

Step 2
Copy the URL without “/overview.aspx” and open Sharepoint Designer, go to “Open Site” and click to open.
image

 

Step 3
Go to “Lists and Libraries” and select “mysurvey” (this is my survey, select yours). Select “Overview” on the right side and double click.
image

The page will be opened, select “Code” (bottom), to see the code of the page.
image

 

Step 4
Go to the section it says <ViewFields> and choose the order you want. The order of these fields will be the order of the output of your spreadsheet. You can add extra fields if you want.

<XmlDefinition>
	<View Name="{E82854CC-2572-4FD2-A2B1-4BD74EE111D6}" DefaultView="TRUE" Type="HTML" TabularView="FALSE" ReadOnly="TRUE" FreeForm="TRUE" DisplayName="Overview" Url="/extranetpresentation/Lists/mysurvey/overview.aspx" Level="1" BaseViewID="3" ContentTypeID="0x" ImageUrl="/_layouts/images/survey.png" CssStyleSheet="survey.css">
		<ViewFields>
			<FieldRef Name="Author"/>
			<FieldRef Name="my_x0020_0_x0020_question"/>
			<FieldRef Name="_x0031__x0020_My_x0020_first_x00"/>
			<FieldRef Name="my_x0020_second_x0020_qestion"/>
			<FieldRef Name="my_x0020_third_x0020_question"/>
			<FieldRef Name="Type_x0020_your_x0020_question_x"/>
		</ViewFields>
		<Toolbar Type="Standard"/>
	</View>
</XmlDefinition>


 


Conclusion: All Responses, Graphical Summary and Overview are the files which control the out of the box survey. We just need to access to these files to customise our “out of the box” surveys.