从 C# 以编程方式访问 Microsoft Project (MPP) 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/153593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Programmatically access a Microsoft Project (MPP) file from C#
提问by Bob
What are my options for programmatically accessing a Microsoft Project file? What are the pros and cons of each approach?
以编程方式访问 Microsoft Project 文件的选项有哪些?每种方法的优缺点是什么?
I will basically need to import all data from the file into another data structure. Using the Office Interop assembies is low on the preference scale.
我基本上需要将文件中的所有数据导入到另一个数据结构中。使用 Office Interop 程序集的偏好度较低。
采纳答案by Rinat Abdullin
Here are the options:
以下是选项:
- Interop (messy and horribly slow for large projects)
- Save project in XML and work with it (messy)
- Save project in the database (that's not publishing and it is available for project 2003 only - see ODBC option while saving). I've seen it being used a lot in the integration scenarios
- Projette(commercial, $10 per license)
- ILog Project Viewer(also commercial)
- 互操作(大型项目的混乱和可怕的速度)
- 将项目保存在 XML 中并使用它(混乱)
- 将项目保存在数据库中(这不是发布,它仅适用于项目 2003 - 保存时请参阅 ODBC 选项)。我已经看到它在集成场景中被大量使用
- Projette(商业版,每个许可证 10 美元)
- ILog 项目查看器(也商业)
回答by Rikalous
The Microsoft Office API provides programmatic access to MS Project. I have only used it for Word and Excel so I don't know how rich the interface is - you will have to do some digging around on MSDN to find out what you can and can't do.
Microsoft Office API 提供对 MS Project 的编程访问。我只将它用于 Word 和 Excel,所以我不知道界面有多丰富 - 您必须在 MSDN 上进行一些挖掘,以找出您可以做什么和不能做什么。
One of the Java projects at my company uses a commerical product by Asposewhich allows applications to manipulate Office documents including Project. It works well for their purposes, but again, they have only used it for Word and Excel so can't offer much advice on Project.
我公司的一个 Java 项目使用了Aspose的商业产品,该产品允许应用程序操作包括 Project 在内的 Office 文档。它适用于他们的目的,但同样,他们仅将其用于 Word 和 Excel,因此无法提供有关 Project 的太多建议。
EDIT (2019): I can confirm that it is a very capable product.
编辑(2019):我可以确认它是一个非常有能力的产品。
回答by Jon Iles
The MPXJ (mpxj.sf.net) library comes in both Java and .Net flavours and will allow you to read and write multiple Microsoft Project file formats using a single consistent API. I am aware of commercial products which use both the Java and the .Net versions of MPXJ without any issues.
MPXJ ( mpxj.sf.net) 库有 Java 和 .Net 两种版本,允许您使用单个一致的 API 读取和写入多种 Microsoft Project 文件格式。我知道使用 MPXJ 的 Java 和 .Net 版本的商业产品没有任何问题。
Disclaimer: I'm the maintainer of MPXJ.
免责声明:我是 MPXJ 的维护者。
回答by Rajesh
Sourcefourge.net offers a component in Java which can be integrated with .net applications to read MPP files upto MPP 2007 the link is http://mpxj.sourceforge.net/getting-started.html
Sourcefourge.net 提供了一个 Java 组件,它可以与 .net 应用程序集成以读取 MPP 2007 之前的 MPP 文件,链接是 http://mpxj.sourceforge.net/getting-started.html
回答by Shahzad Latif
You may use Aspose.Tasks for .NET. This component allows you to work with Microsoft Project files. It doesn't require MS Office to be installed on the server, unlike Office Interop. The API is very simple and easy to use. And it provides a rich set of features to read, edit, write, and convert MPP files.
您可以将Aspose.Tasks 用于 .NET。此组件允许您使用 Microsoft Project 文件。与 Office Interop 不同,它不需要在服务器上安装 MS Office。API 非常简单且易于使用。它提供了一组丰富的功能来读取、编辑、写入和转换 MPP 文件。
This component is a normal .NET assembly which can be used with your .NET applications. It works on any Windows OS and in 32/64-bit environments as well.
此组件是一个普通的 .NET 程序集,可与您的 .NET 应用程序一起使用。它适用于任何 Windows 操作系统和 32/64 位环境。
Disclosure: I work as developer evangelist at Aspose.
披露:我在 Aspose 担任开发人员布道者。