Saturday, May 5th, 2007

Exposing Excel contents to make reporting easy in SharePoint



This article will show how simple it can be to use the out of the box features of SharePoint and Office documents to provide powerful reporting on you documents. This example will look at the common scenario where a SharePoint (this will work with standard WSS) document library is used to store invoices.

Problem:

In order to forecast the projected income I need to maintain a separate summary spreadsheet which often gets out of step with the actual invoices.

Solution:

Out of the box SharePoint is able to interrogate custom properties from an Office document, using these features and the ability for Office documents to link these properties to document contents we are able to surface valuable information from the Excel Invoice into document library properties and use these to create powerful reports that will always be up to date.

Create Custom Document Library

Create a new document library and add the following custom columns

  • Order Number – Text Field
  • Invoice Amount – Number Field
  • Invoice Date – Date Time
  • Payment Date – Calculated Date Time [Invoice Date]+ 30

In this example I have used a default payment term of 30days. It would be possible to extend the solution to extract the payment terms from the spreadsheet and base the calculated column on the [Invoice Date] + [Payment Terms] if you had a customer specific requirements.

Create Excel Document Template

The example is based on the Excel 2007 Online template; your template can be based on your own Invoice format. If you want to use the template when selecting New from the menu in SharePoint it will need to be based on Office 2007.

Excel makes it very easy for you to expose named cells as custom properties so we will use this feature to name the parts of the invoice spreadsheet we want to surface.

For each of the following cells within the spreadsheet select it and add a name by typing the name in the Name Box.

  • OrderNumber
  • Amount

The one area that we will need to do some formatting is to ensure that the Invoice Date is formatted in a way that SharePoint understands as a date. In the picture above we have created a formula in a cell that will do this for us.

=TEXT(Invoice,”yyyy-mm-ddThh:mm:ssZ”)

This format is based on the ISO8601 format; more details can be found here CreateISO8601DateTimeFromSystemDateTime

Name this new cell InvoiceDate; you can also make this cell hidden.

Now we have all of the contents of the document named we can promote these to custom properties, this is probably the easiest bit! From the ‘Office Pearl’ or what ever you want to call it – choose Prepare > Properties

This will present you with the standard document properties form, select the Advanced Properties option to display the traditional properties dialog.

 

Add the following Properties by typing the Name (it must match the SharePoint column name above exactly), tick the Link to content box and select the correct field from the dropdown. If you don’t see a field it is because the field name was not saved, check as above and repeat.


Order Number –
select OrderNumber
Amount - select Amount
Invoice Date – select Invoice Date
You should see something like the screenshot below.

Do not worry that the Invoice Date field is marked as a Text type; we have formatted the text so that SharePoint will be able to add this to its Date field.

Save the document.

Uploading to SharePoint
before we add the template to the document library we will test the upload works.

Fill in a sample invoice with Date, some sample lines and an Order Number. Save the document and upload the document to the SharePoint document library. This should present you with a screen similar to this

All of the fields should be filled in automatically with the values you entered in SharePoint!

The document library should then look something like this

Give users easy access to your template

SharePoint make it easy for you to make this template the default on used when people click the New button. Clean up the test contents from your spreadsheet, add protection and hide cells as required, and save the file as template.xlsx.

In your document library click Actions > Open in Windows Explorer

This will present you with a window like this

Copy your template.xlsx file into the forms folder; this will replace the out of the box template for this library.

Create some reports

I will not walk you through the types of reports you could create but using standard list features and the fact you now have the information surfaced it will be easy to interrogate the information as required.

Possible options
1. Forecast showing sum of income based on invoice due dates
2. Payments overdue – show all payments overdue, add another calculated column to show ranges to help chase late payments

That’s it!

It works better on file upload then through Office Integration!

There is an issue where if you use Office Integration the user will need to manually update the values in the form presented in Excel. This form takes precedence over the calculated values in the custom properties.

Next task, how to get the custom properties form to update dynamically with the correct values?

 

  • Markus
    Like most people here I wasn't able to send custom properties in the Excel document into server properties (user defined columns in a SharePoint 2010 list) when using the "New Document" button in the document library.

    The solution is to use a small VBA code, which reads the cell-values and puts them into the server properties.

    The solution can be found here...
    http://markiwaszko.blogspot.com/2009/02/binding...

    ... and here ...
    http://amatterofdegree.typepad.com/a_matter_of_...

    I had to use a xltm-file as template to make the code work when the document is generated out of SharePoint.
  • JoeW
    Much heartache and wasted time for many people fighting with DIP and WSS functionality (or lack thereof.) My comments are specific to Excel 2007 and WSS 3.0, so proceed accordingly.

    The issue seems to be achieving some sort of synchronization between content types (with their associated site columns) and DIP s that appear to be auto-generated when Excel documents are uploaded to document libraries that have content types defined along with a custom template. We ran into this problem when we started adding and deleting site columns from our custom Content Types. The DIP just seemed to ignore these changes, no matter what we did. This is where the profound differences between Office Integration (Create New Document) and WSS Content Management (Upload an existing document) showed up.

    Once you have followed the steps listed in this article, add the VBA code referred to in Markus' comment - but you still aren't out of the woods yet. You must add sample data to your "template" that will populate the ContentTypeProperties you wish to push up to WSS, then upload this document into your document library. Opening the uploaded document from the library and looking at the DIP, you will find all of your custom server-based properties where they should be. Clear out the sample data and save your template back to WSS. Then update the Content Type definition to point at the new template that will be called when someone chooses "New" from the document library menu bar.

    We spent a lot of frustrating hours trying to coax the DIP into showing our revised content columns, even resorting to InfoPath edits and publishing forms - none of it worked until we followed this process. I suspect that much of this has to do with the incomplete support for DIPs in WSS, versus the explicit support in MOSS. One more gotcha for those of us who figured that WSS was "good enough" that we could save the bucks on MOSS...
  • niallramsey
    This isn't working for me either. I'm using Excel 2007 but using the Microsoft's Online Services (BPOS) for SharePoint ... Not sure if this makes a difference?

    Would love to get this issue handled because we input quite a bit of Metadata into our documents, and then to be not able to filter/search/sort on that in SharePoint without re-typing it all is very frustrating !
  • Name
    I have followed the steps exactly as they are posted, but when I create a new document from the library I have notice it's not pulling any of my properties data into the library. When I select advanced properties I think notice that my cells are no longer linked. For some reason it's as if the properties that i customized aren't sticking.
  • Jimmie
    Ok, i created my own Form and the document library with a few fields for my company. I am able to get this method to work only when i upload a document from my computer. I tried going in and modifying the existing template as well as your method of going into the forms folder itself and changing the template file with my file that worked for the upload. This is a great option, but if it does not work by using the New Button then it is not very useful. Has anyone else had this problem?
  • I'm having this annoying issue as well. I can't find anything on google about it! Does anyone have an update. I'ved ended up using manditory fields, the one thing I didn't want to do.
  • Patrick
    I am having the same issue. I see the Server Properties and the standard Document Properties, but when a user selects "New" from within the doc library, and completed the form, the values in the named cells do not promote to the server properties.

    Has anyone found a solution for this? Shouldn't this be a LOT easier (Microsoft)?
  • Andrei
    Yup, that was pretty much the idea, I know: getting them to update/populate automatically. I think you can also achieve that functionality in a programatical way, but that is beside the point as well :)


    I think the key to the problem is the appearance of the second set of properties, server side. I will dig more into it and if a find a clear result I will let you know as well.
  • Andrew Woodward
    Andrei,


    I have not tried this but I can see how this could help, although it would require the users to manually set the values - something I was trying to avoid in this scenario.
  • Andrei
    Hello. I'm experincing the same problem with custom properties for Excel documents. Have you considered using a workaround to obtain the same functionality: ie using Content Types or Custom Document Information Panels, and if so, to what result?
  • Andrew Woodward
    Ben,


    Unfortunately I have not been able to solve the problems with updating values or office integration. I would be very interested to hear from anyone who has had success with this.
  • Ben
    Any luck in getting values to update dynamically or improving the office integration?
    I find that if I download the file and change it, my newly updated values never get posted back. Similarly if I create a new file from the associated content type template it just sticks with the values in the template. I've googled this for ages and found lots of solutions for Word but not much for Excel!

    Any thoughts?
blog comments powered by Disqus