Programmatically access a Microsoft Project (MPP) file from C# - c#

What are my options for programmatically accessing a Microsoft Project file? What are the pros and cons of each approach?
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.

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.
Disclaimer: I'm the maintainer of MPXJ.

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.
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.
Disclosure: I work as developer evangelist at Aspose.

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)

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.
One of the Java projects at my company uses a commerical product by Aspose which 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.
EDIT (2019): I can confirm that it is a very capable product.

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

Related

Replace use of excel interop

I have a system which does heavy use of excel interop.
this is problematic , because it is deployed at many client sites,
each with his own unique operating system, office version , regional settings etc...
This causes me headeaches like this one:
OleDB & mixed Excel datatypes : missing data
It is hard to reproduce or solve this bugs.
Also, I can't run my system as a windows service, because of known issues with using interops at a windows service.
So what I'm looking for is a tool which will allow me for excel import\export without me using the interop. it should ideally:
Support excel 2003 - 2013 and hopefully upcoming versions
Support getting values and writing values to excel (of course)
Support styling operations (font , range of cells, borders, etc...)
Support use of graphs in excel
Support macros activation.
support csv files
This is all I can think of for now :-)
Would appreciate any help. Thanks.
Office Interop can cause a compatibility problems, you need to have a valid office license installed and... is slow...
Probably the best Open solution is to use the Open XML SDK. It's well documented and Microsoft encourages the developers to use this approach over Interop.

Generating an Excel File Example for Visual Studio 2010 and ASP.net and C#

I've come across ExcelPackage and I found a couple of examples of using it, but none seem to work, they've all got some aspect, component missing or are for a different version of Visual Studio. I simply need to generate a .xls or .xlsx or even a .csv file, but as I am using a 3rd party server I can't use the Office .com objects. I have used SpreadsheetGear in the past which is expensive and as I am retired, I can't afford this sort of product.
If anyone has a working example of ExcelPackage or any other freeware offering, or can point me in the direction of one that has everything I need, it would be appreciated. A regular Web App rather than MVC would be preferred.
Take a look at Simplexcel by Michael Stum. It is designed around simplicity, is fully supported under ASP.net and should allow you to make simple, but extremely usable Excel cheats. You have an simple example available here.
Check out the Open XML SDK. This gives you the ability to generate and manipulate Office documents without using Office itself or the interop, and as such makes it a suitable approach from the server-side.

What are the available 3rd party options to a) modify a templated word document b) convert a docx to pdf

What are the available 3rd party options to
(a) modify a templated word document
(i.e., replacing values with those
template fields in the docx file).
(b) convert a docx to pdf
I've already implemented this using Primary Office InterOp and those COM Office components, however, the problem is that the component is going to be used under an ASP.NET app, and therefore, the Office itself cannot be installed on the server.
So, I'd like to know what are the available 3rd party options out there to handle such cases.
Any help would be highly appreciated,
TIA,
I've not used it myself, but you could try Word Automation Services.
A couple of years ago I worked on a project that had been built to use the Aspose software. It was pretty easy to use and pretty powerful. It is definitely not free, but they do package the software so that you only buy the features you need.
If money is no big deal, have a look at http://www.textcontrol.com/en_US/
(a) Use content control databinding (an OpenXML feature built into Word 2007 and later)
(b) docx4j IKVM'd as a DLL
Have a look at Open Office dot Org. The conversion fidelity may not be perfect, but it will be Free.

How can I use DOT files to export data's?

I need to export data into a word doc using ".dot" models, with an application written in asp.net.
Can you give me some links to learn this trick? I'm sure is it possible without any external libraries.
Thanks to the universal knowledge ;-)
I doubt you will able to do this without any extra libraries.
If you are using Word 2007+ format (eg .docx, .dotx) you can use the Open XML SDK. If not, your best bet is probably Aspose.Words
You'll need to have MS Word installed on the machine that will fill the templates (.dot files), and then you can call an instance of Word to do the replacements for you, using Microsoft.Office.Interop.Word.
If this has to be implemented on a server, you might have a problem. Microsoft advises against installing Office on servers because of stability and reliability issues. http://support.microsoft.com/kb/257757 focusses on some of these problems and also mentions some alternatives.

Reading a Excel 2007 Spreadsheet in C#

I've done some googling and there seems to be a plethora of tools for reading excel 2007 spreadsheets using c#. I'd like to know which one performs best and is easy to use.
Frankly, it depends on if you have Excel installed on the machine.
If you have Excel installed, using Microsofts Office APIs is as quick and ( for the price ) painless as you are going to get. That said, if you don't have Excel installed, the question gets much trickier.
Also, note, if you are installing to a web server that is available to the world, using Microsoft's Office APIs often isn't actually legal, as the end user needs to have an office license for you to be legal. If this is the case, and you are developing for redistribution or internet deployment, make sure that the library you are considering has no dependencies on the Office APIs, as their redistribution isn't actually legal either. If you need to, for example, provide a viewer for people that don't have Excel installed, you can't legally use the Office APIs, nor can you use 3rd Parties that depend on that layer. Compliant libraries will make it clear in their description that they don't depend on Excel.
It depends what you're trying to do with the spreadsheet.
If you want to read tabular data, OleDB is the best option.
If you want to read formatting or specific cells, you should use a third-party component. (I can't recommend a specific vendor)
You should avoid using Excel's COM object model unless you want to interact with an open window or print a spreadsheet.
I've had pretty good results with Koogra.
Check the Open XML SDK. It includes a "Productivity Tool" that lets you walk through the structure of a document to help write your code as well.
I looked into the Open XML Format SDK about a year ago and it seemed like a good alternative that does not require Office installed.
I have used GemBox and the Microsoft Office APIs to read in spreadsheets. I have had success with both options but I tend to like GemBox a bit more. It is fast and simple to implement but comes with a price tag.

Categories

Resources