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.
Related
My C# Windows application needs to print office documents silently(without popup dialog or open up applications such as Word, Excel ). So I'm trying to find a way to print office documents without office (Otherwise user needs to buy office package also to use my application).
I tried with Aspose.NET but It seems some parts of the documents(such as notes, comments) are getting ignored by this component.
I've also tried to go through Microsoft Office 2010: Primary Interop Assemblies Redistributable. But, as I found to use MS office PIAs, MS office needs to be install in the target computer.
Any ideas where should I look into?
First you should understand, that MSOffice uses a proprietary format, that event he best open-source office software is having problems reading without screwing something up.
My suggestion is - you either take something that does a minimal amount of damage, or require office. One suggestion would be: Microsoft used to make "word reader" and "excel reader", try to see if they are still being released.
Another idea would be to find a free office-to-pdf or office-to-xps conversion software, include it with your program and print.
The most difficult way, in my oppinion, would be to feed the document to some online service, for example skydrive's document reader, and request it to print the file.
Depending on the application, your best bet might be saving the content to Open XML and parsing it (beware there's a lot of bloat in larger documents saved in that format per my experience) or simply saving to PDF.
Another clunkier, but more standalone possibility is to use control.click and such to build an automated clicker that opens content in an external freeware application and prints it. The most compelling option is Microsoft's "Viewer" applications (when available). When that is unavailable for a particular document type, Microsoft suggests OneDrive as a freeware alternative (requires account, internet connection).
Word -- "Viewer" has been retired, look for legacy version or use OneDrive
Excel -- "Viewer" is available
Powerpoint -- "Viewer" is available
If you don't want to use a third party application, that could give you a creative, if clunky route to accomplishing your posted goal. Good luck!
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.
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
(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.
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.