Jaa


Updating demos from my book for the DC SharePoint Best Practices Conference

I’ve been updating some of my demos for the upcoming DC SharePoint Best Practices Conference (https://www.bestpracticesconference.com/). Basically, I have a session that shows different approaches to common document generation scenarios that customers have expressed an interest in. I will show why you want to be building these out with SharePoint and why you want to use some of the latest tools to help. These tools are things like the new Visual Studio Extensions for WSS, the new Open XML SDK, and the Word Content Control toolkit. Some of the demos in my session (on the first day of the conference) were solutions that I first proposed in my book: Pro SharePoint Solution Development. Those solutions were built on (gasp) VS.NET 2005 and the Packaging API which was brand new back then. For those of you who have been looking for an update, here you go. Here are some download links to updated projects:

A web part for building a PowerPoint presentation server-side:

https://cid-601cfa765e7a6fd3.skydrive.live.com/self.aspx/Public/DynamicPowerPoint.zip

A new feature that merges SharePoint list data into a Word document template:

https://cid-601cfa765e7a6fd3.skydrive.live.com/self.aspx/Public/CustomerDocumentsFeatureNew.zip

A new feature that supports the splitting of a document into discrete sections and then merged back:

https://cid-601cfa765e7a6fd3.skydrive.live.com/self.aspx/Public/DocumentSplitter.zip 

Just a reminder that all of these solutions are really just demo code and should have a lot more error handling and testing. But it gives you a really good starting point for your own solutions. The biggest difference with these new projects is the use of the Open XML SDK which gives you an object model to work with instead of coding nasty XML. Here is an example of an old code snippet that opened up a PowerPoint template and located the slide parts:

Using pptPackage As Package = Package.Open(fileStream, FileMode.Open, FileAccess.ReadWrite)
           ' Get the main document part (presentation.xml).
For Each relationship As PackageRelationship In pptPackage.GetRelationshipsByType(documentRelationshipType)
documentUri = PackUriHelper.ResolvePartUri(New Uri("/", UriKind.Relative), relationship.TargetUri)
documentPart = pptPackage.GetPart(documentUri)

               ' There is only one document part. Get out now.
Exit For
Next

           ' Manage namespaces to perform Xml XPath queries.
Dim nt As New NameTable()
nsManager = New XmlNamespaceManager(nt)
nsManager.AddNamespace("p", presentationmlNamespace)
nsManager.AddNamespace("a", drawingmlNamespace)

            ' Iterate through the slides and extract the title string from each.
Dim xDoc As New XmlDocument(nt)
xDoc.Load(documentPart.GetStream())

            Dim sheetNodes As XmlNodeList = xDoc.SelectNodes("//p:sldIdLst/p:sldId", nsManager)

And see how this changes with the new SDK:

Dim presDoc As PresentationDocument = PresentationDocument.Open(fileStream, True)
Dim presPart As PresentationPart = presDoc.PresentationPart
Dim presentation As DocumentFormat.OpenXml.Presentation.Presentation = presPart.Presentation

If (Not (presentation.SlideIdList) Is Nothing) Then

   ' Get the title of each slide in the slide order.

   For Each slideId As SlideId In presentation.SlideIdList.Elements(Of SlideId)()

Just a reminder that you need these add-ons to VS.NET 2008 to work with these projects:

Visual Studio Extensions 1.3 March Preview:

https://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=fb9d4b85-da2a-432e-91fb-d505199c49f6

Open XML Format 2.0 SDK April Preview:

https://www.microsoft.com/downloads/details.aspx?FamilyID=c6e744e5-36e9-45f5-8d8c-331df206e0d0&DisplayLang=en

Comments

  • Anonymous
    August 04, 2009
    The updated PowerPoint web part produces the following error on my demo VM: PowerPoint was unable to display some of the text, images, or objects on slides in the file... It seems to have a problem rendering the Software Issues slide. Have you run into this error?  If so, how did you fix it? I'm running MOSS 2007 Enterprise SP2, Office 2007 Ultimate SP2 with all Microsoft updates through June 2009.