views:

1330

answers:

9

Interop library are slow, and need MS Office installed. Many times you don't want to install office on servers.

I'd like to use Apache POI, but I'm on .NET.

I need only to extract the text portion of the files, not creating nor "storing information" in office files.

I need to tell you that I've got a very large document library, and I can't convert it to newer XML files.

I don't want to write a parser for the binaries files. Library like Apache POI does this for us. Unfortunately, it is only for the Java platform. Maybe I should consider writing this app in Java.

Still not finding an open source alternative to POI in .NET, I think I'll write my application in java.

Thanks.

+1  A: 

What do you need to do with those file? If you just want to stream them to the user, then the basic file streams are fine. If you want to create new files (perhaps based on a template) to send to the user that the user can open in Office, there are a variety or work-arounds.

If you're actually keeping data in Office documents for use by your web site, you're doing it wrong. Office documents, even Excel spreadsheets and access databases, are not really an appropriate choice for use with an interactive web site.

Joel Coehoorn
Nothing like that. I need to extract the text part of the files.Thanks, bye.
volothamp
+1  A: 

If the document is in word 2007 format, you can use the system.io.packaging library to interact with it programatically.

RWendi

RWendi
Thanks, but I need all MS Office Files.
volothamp
A: 

OpenOffice.

You can program against it and have it do a lot for you, without spending the money on a license for the server, or have the vulnerability associated with it on your server.

+2  A: 

As the new docx formats are inherantly XML based files, you can create and manipulate them programmatically with standard XML DOM techniques, once you know the structure.

The files are basically zip archives with an alternate file extension. Use the System.IO.Packaging namespace to get access to the internal elements of the file, then open them into a XmlDocument to perform the manipulation.

There are examples available for doing this, and the Office Open XML project on SourceForge may be worth looking at for inspiration.

As for the older binary formats, these were proprietary to MS, and the only way you're likely to get at the content from within is through the Office object model (requires an office install), or a third party file convertor/parser.

Unfortunately there's nothing first party and native to the .NET platform to work with these files.

ahin4114
+3  A: 

For all MS Office versions:

For the new Office (2007):

For the old Office (before 2007):

Ilya Kochetov
TX Text controls reads only word's files. Do you know if other exists?
volothamp
@volothamp yep :)
Ilya Kochetov
A: 

Microsoft Excel workbooks can be read using an ODBC driver (or is it an OLE DB driver? can't remember) that makes the workbook look like a database table. But I don't know whether that driver is available without the Office Suite itself.

pdc
+1  A: 

Check out the Aspose components. They are designed to mimic the Interop functionality without requiring a full Office install on a server.

Jason Z
A: 

You can use OpenOffice has a command-line conversion tool:

Conversion Howto

In short, you define a macro in openOffice and you call that macro with a command-line argument to openoffice. In that argument the name of the local file (de Office file) is encoded.

It's not a great sollution but should be workable.

extraneon
+1  A: 

In Java world, there is also JExcelApi. It is very clearly written, from what I was able to see, much cleaner then POI. So maybe even a port of that code to .NET is not out of the question, depending of course you have enough of time on your hands.

javashlook