Export Document Version to Excel Spread Sheet in SharePoint


I got a requirement from my client to view the document version number in excel export, so I have shown the Version column in the library view and then I have exported the data to excel, I was surprised because I didn’t get the version number to excel export. You might also face same kind of issue. I have found a quick solution for this.

Create a Calculated field named “Version No”

In the above image you can observe that I have written “=[Version]” in the formula section, because by default you will not get the “Version” column in “Insert Column” section. You have to write the Version there to get the document version in the excel export.

Now show the calculated column “Version No” in the Library view, you can see the Version column value in the “Version No” (Calculated field).

You can hide the default Version column and show the calculated field “Version No” and export to excel and see, now you would get what you wanted. 



Point to Remember: When you edit the document, “Version No” column value will become Zero “0”, but don’t worry we can get back the version number to “Version No” by open the list settings and go to the “Version No” column and open and click ok. Now you will see the “Version No” is updated with the new version number. I know it is not a perfect solution but we can use this as a quicker one. Hope it helps :)

Create/Insert SharePoint List Items using ECMA Script (JSOM/Client Side Object Model)

Insert SharePoint list items in simple steps using Client Side Object Model.

Step 1: Create a SharePoint list, for eg: i have taken a list name "Cars" and i have created two fields "Car Name" and "Price" both are free text fields.

Step 2: Now we have to create a front end for the user to create list items, to do this we need to have knowledge on HTML. Here I have written my HTML code in the content editor web part, I have created two HTML Textboxes, one button for submitting the item to SharePoint list.

 <table>
<tr><td>Car Name</td><td><input type="text" id="txtCar" /></td></tr>
<tr><td>Price</td><td><input type="text" id="price" /></td></tr>
<tr><td colspan="2"><input type="button" id="btnAddCar" onclick="AddCar();" value="Submit" /></td></tr>
</table>


Step 3: I have embedded the Step 2 HTML code and the Javascritpt code in the content editor. You can find the complete code below. Replace the bolded letters in the below code with name of your internal field names. 

<Sharepoint:ScriptLink name="SP.js" runat="server" OnDemand="true" localizable="false" />
<script type = "text/javascript">
function AddCar() {
var txtCar = document.getElementById("txtCar");
var cost = document.getElementById("price");
if (txtCar.value == "") {
alert("please enter a car");
return;
}
var clientContext = SP.ClientContext.get_current();
var webSite = clientContext.get_web();
var lists = webSite.get_lists();
var carsList = lists.getByTitle("Cars"); // Here "Cars" is my list name
var itemCreationInfo = new SP.ListItemCreationInformation();
var listItem = carsList.addItem(itemCreationInfo);
listItem.set_item("InternalFieldName", txtCar.value); //specify the internal field name
listItem.set_item("InternalFieldName", price.value); // specify the internal field name
listItem.update(); //updating the item into the SP list
clientContext.executeQueryAsync(
Function.createDelegate(this,this.Succeeded)
,Function.createDelegate(this,this.Failed));
resetVal(); // calling function resetVal()
}
function resetVal()
{
document.getElementById("txtCar").value = ""; //Clear textbox after submit the item
document.getElementById("price").value = ""; //Clear textbox after submit the item
}

function Succeeded(sender,args) {
alert("Succeeded");    // Success message, after submit the item.
}
function Failed(sender,args) {
alert("fail"); //Failure message, after submit the item.
}
</script>
<table>
<tr><td>Car Name</td><td><input type="text" id="txtCar" /></td></tr>
<tr><td>Price</td><td><input type="text" id="price" /></td></tr>
<tr><td colspan="2"><input type="button" id="btnAddCar" onclick="AddCar();" value="Submit" /></td></tr>
<tr><td colspan="2"><label id ="lbl" runat="server"/></td>
</table>



Hope it helps :-)