简体   繁体   中英

How to create a report, as a Word document, from data in a Sharepoint list

I have a sharepoint list that is used to record weekly activity, eg four columns for weeknumber, projectname, customername, comment

I'd like to be able to generate a report containing all the data for a particular week in the following format

  • ProjectName 1
    • Customer 1
      • Comment 1
    • Customer 2
      • Comment 1
  • ProjectName 2
    • Customer 3
      • Comment 1
    • Customer 4
      • Comment 1

I can do this by exporting the list to an Excel file and then writing some VBA to generate a Word Document, but I'm wondering if there is any way to cut out the Excel step.

Open Xml ?

I found it quite a steep learning curve to get into, but very powerful. I'd suggest that this is a more elegant approach than vba (in that you are dealing with strongly-typed classes) but not necessarily quicker.

So there's two parts to this

a) Getting the data from SharePoint.

b) Converting it into a Word document.

For a) You will probably end up running this remotly (ie not on the sharePoint server) as automating office apps on a server is not recommended - so you should look into the SharePoint Web Services to access your data.

For b) You can use - Office Automation (via VBA or C#, VB.NET etc) - Open XML as Pete suggests ( Example running in SharePoint ) - A commercial component such as Apose The last two will allow you to run your code on the SharePoint server

There is nice example on Github (FoodOrder) on how to do it with Templater.

As author I highly recommend it ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM