I would like to use NPOI library to get image from Word file (Doc [97-2003]).
I want to HWPFDocument class, but i can not find namespace, where this class is. I write code in c#.
I don't think you can achieve that using NPOI.
As tonyqus (the guy behind the project) states here and here HWPF is not stable and usable.
I've managed to work with MS Word and Excel with "OpenOffice uno SDK".
It's not straightforward but after a little bit of struggle you can have great results.
You can read how to extract and use the assemblies here and how to achieve what you're looking for here.
Of course you can always use MSOffice Interop but you need to install MS Office on the client where the application is executed.
Hope it helps.
Related
Is there any way in .Net to convert an MS Office Powerpoint .PPT to .ODP?
I've searched the web, and I only see so-called online converters. I've ony found one commercial option, Aspose, which starts at $500.
Thanks.
There's nothing built in. You're looking at a third party library.
One option I know can work and is fairly easy to do is unoconv. It's just a command line script you can call. The problem is that you take on a lot of dependencies. You need Open Office installed, and the script is in python so you need that available, too.
There is a free online converter like alterapps.com , This works for me all the time. quick and efficient.
I am developing an application which primarily imports spreadsheet reads the data and manipulates it.
I was googling all day, unable to find a way to read data from excel files.
It would be great if I could get some help to do the required.
Information :
I am developing Windows Store app using C#/XAML.
Reference libs/apps which read excel :
http://www.componentone.com/SuperProducts/SpreadNET/
http://www.greatwindowsapps.com/app/tile-charts
If you look for a free open source solution, I used in several projects exceldatareader from codeplex lib, very simple and easy to use.
It depends only by SharpZipLib, I think that you have only to recompile both projects as portable libs to make it work on WinRT.
If you're working with .xlsx files there's always Open XML SDK which you can get from NuGet as well. Here's a bunch of tutorials to get you started. Unfortunately the really nice wrapper library ClosedXML doesn't work with Windows Store apps.
There's also a commercial component available, XlsIO from Syncfusion, which you could try out. I don't have any first hand experience with it.
I posted the same the question in the MSDN Blog
http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/4fce4765-2d05-4a2b-8d0a-6219e87f3307
Code provided by VT.CrazyAppy works fine for reading & parsing simple spread sheet file.
The code snippet is static , I am working on it to make it more generic.will post the code
once I done with that.
Note : The code will provide a mechanism to read a simple spread sheet file and return them as K,V pair.
You can modify it to suit your need.
I wish to know is there someother way that allow us to operate MS word in C#.NET platform. Or that we can only use Office.Interop to achieve that?
I am kind of confused to that. Can you explain some skills or resource for me to find out step by step. Thanks.
I can handle "Interop" myself or by googling it. I wish to know something new to me, so I can find out with your explanation. Any idea?
There are several ways to operate with Microsoft Word documents without Office and Interop.
OpenXML
3rd party components
OpenXML
All what you need for it is OpenXML SDK. There are set of .NET classes thre that allows you to completely manipulate or create Word documents, of course in OpenXML fomat - docx. For example googled video on Channel 9 with intro to OpenXML link for you to start, and article about it.
Using OpenXML is considered as a low level way to manipulate docx
3rd party components
For example, on several my projects we have used Aspose components. It can make development easier and is not bound only to OpenXML format, so you can manipulate doc/docx. But with OpenXML you have full control on what your code is producing and with 3rd parties you are depending from external components, that in some rare situations can generate not what you are expecting.
I'm sure there are many other 3rd parties. But Aspose is that, I've used on 2 production projects, and it seems to be good enough for them.
You can look at Aspose demos.
Has to be free.
Has to support all versions of Excel files.
Has to have C# .NET API.
I need to do all of the specified actions (reading/creating/updating).
Has anyone used any library l this kind sucessfully
Update:
I read a lot of bad things about Ole DB, and Interop is not an option since this is a web application running on a server.
Try to use OleDB Reading Excel files from C#
From a previous answer on a different question:
You might consider using the Excel object model and COM interop to read the data from the Excel file into your application. Granted, this includes a dependency on Excel being installed, but it is a possibility. This article has some great code for getting started with reading Excel files in this way.
A better way might be to use a library that doesn't have a dependency on Excel being installed on the local system. This answer suggests using the Excel Data Reader library, available on CodePlex.
Like I pointed out in my other answer, there are paid third-party libraries that will likely do exactly what you are looking for. I understand you want something that is free, but in my experience with free Excel libraries, you tend to need to do a good bit of extra work to get it to play the right way.
I'm a big fan of Aspose Cells. It does all you want but it isn't free. I don't know any other products that can fit all your needs (All Excel Versions, C# Api, Read/Write, etc)
I'm looking for any available free Excel "helper" classes that are written for .net (doesn't have to be C#).
I'd like to evaluate what others consider to be useful and generic static (and non static) helper methods.
Can be targeted at VSTO or regular Office automation, although that probably doesn't matter.
I guess I should also point out that this question is NOT asking for "what are good alternatives (or free alternatives) to using Excel object model automation. I don't really want links to SS gear, etc, although they are all great products that's not the purpose of the question.
In case I wasn't clear enough in the previous paragraph: I don't want answers that state - use this free (or not free) 3rd party component, instead of Excel object model code.
So basically what i was asking for was user developed C# code libraries that contain VSTO, Office or Excel helper functions such as static methods for working with menus, ribbons, ranges, workbooks, documents, xml (such as the ones otaku mentioned)...
VSTO Power Tools is a good set of utilities to work with Excel:
http://msdn.microsoft.com/en-us/magazine/dd263100.aspx
ExcelDNA is a very cool project. It provides a lightweight way to consume .NET code from Excel, with a deployment model which is much easier than VSTO. I found it an interesting alternative to VSTO if you want to write UDF in .NET for instance.
In terms of Office automation for Excel, there are some good PowerShell Open XML cmdlets that can be used for PS or ported to C# at Announcing the Release of PowerTools for Open XML V1.1. Eric White's blog, where this link is, has recently done an more in depth look at Excel automation using Open XML, like Table Markup in Open XML SpreadsheetML. Note about Open XML - although it is the preferred method by many, you don't actually have to use the Open XML SDK - you can just use System.IO.Packaging to gain access to Excel 2007/2010 files.
Also, often overlooked, but the Excel snippets available for VSTO, Open XML and Interop development are great. 1, 2, 3
Also, check out the Excel samples for VB # http://msdn.microsoft.com/en-us/library/8x19fbw1(v=VS.90).aspx. These come installed with VS when you also choose VB as a language during the install.
Update: Just discovered the All-In-One Code Framework (Office) which has a lot of great Excel helper classes. You can find it on: http://1code.codeplex.com/releases/view/51868.
For VSTO projects:
http://www.add-in-express.com/
Non-VSTO, non-automation:
http://www.html-to-pdf.net/excel-library.aspx
Note: neither of these libraries are free.
There's one called FileHelpers which enables you to save Excel data as CSV and the FileHelpers library can easily parse the information and so on, sure it may not be fully blown Excel automation, but it is a good headway to parsing. If you're talking about being able to deal with Excel in a native binary fashion, then this article from CodeProject might help, also here, is BIFF parser that understand the underlying excel data storage, and also here on CodeProject.
With .net 4.0 dynamic keyword writing Excel automation easy as hell.
If you want intellisense you can easily write c# wrapper on top of dynamic calls.
UPDATE
We are working with Excel automation since 2001 (developing financial addins).From Excel 2000 up to 2010.
And all we know that standard interop simply does not work when your code should work with all versions and service packs of Office.
We had beaten many times by custom interop libraries, VSTO versions, etc. After a year we found a only one solution that works - call all automation via late bound calls (reflection). i.e. (''notepad code'') Type.GetTypeFromProgId('Excel.Application').GetMethod('Visible').Invoke(....).
But code was very big and ugly, then we simply wrap that ugly code with Object Model copied from Excel 1:1. When we need new method we add it to our Excel Object model and call excel automation via late bound call.
With new dynamic keyword it is possible to live without wrapper especially with Resharper's dynamic support.
I prefer this one:
Excel Package on CodePlex
it uses the Open XML, so no need for an office install on the computer (may or may not factor in), but I found it very easy to use and set up.
I really like NPOI for 2003/2007 formats
http://npoi.codeplex.com/
Totally standalone and easy to use