简体   繁体   English

如何从Sharepoint列表中的数据创建作为Word文档的报表

[英]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 我有一个用于记录每周活动的sharepoint列表,例如,周列数,项目名称,客户名称,评论的四列

I'd like to be able to generate a report containing all the data for a particular week in the following format 我希望能够以下列格式生成包含特定周的所有数据的报告

  • ProjectName 1 ProjectName 1
    • Customer 1 客户1
      • Comment 1 评论1
    • Customer 2 客户2
      • Comment 1 评论1
  • ProjectName 2 ProjectName 2
    • Customer 3 客户3
      • Comment 1 评论1
    • Customer 4 客户4
      • Comment 1 评论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. 我可以通过将列表导出到Excel文件然后编写一些VBA来生成Word文档来完成此操作,但我想知道是否有任何方法可以删除Excel步骤。

Open Xml ? 打开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. 我建议这是一种比vba更优雅的方法(因为你处理强类型的类)但不一定更快。

So there's two parts to this 所以这有两个部分

a) Getting the data from SharePoint. a)从SharePoint获取数据。

b) Converting it into a Word document. b)将其转换为Word文档。

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. 对于a)您可能最终运行此远程(即不在sharePoint服务器上),因为不建议在服务器上自动执行Office应用程序 - 因此您应该查看SharePoint Web服务以访问您的数据。

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 对于b)您可以使用 - Office Automation(通过VBA或C#,VB.NET等) - Pete建议的Open XML( 在SharePoint中运行的示例 ) - Apose等商业组件最后两个允许您运行代码SharePoint服务器

There is nice example on Github (FoodOrder) on how to do it with Templater. Github (FoodOrder)就如何使用Templater做了很好的例子。

As author I highly recommend it ;) 作为作者我强烈推荐它;)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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