I have a WPF application and I need to generate an excel file that also contains charts? What is the best way of doing that? If possible, I want to avoid using the excel interop.
Thx,
L
Look at this http://epplus.codeplex.com/wikipage?title=StatisticsSheetExample
I just found http://epplus.codeplex.com. Think I'm going to give it a try, it supports charts.
OfficeWriter is another mature .NET library for Excel that supports adding charts:
http://www.officewriter.com
Related
I'm currently busy with a task that involves both manipulating data in an excising excel document as well as the sheet itself.
In the past I've always used OleDbConnection and OleDbCommand to work with excel, but I've been reading about something called a Workbook and I'm not sure which way I should go about this.
Some examples of what I need to do include-
Inserting a new column
Deleting old columns
Setting a cell a certain colour depending on it's contents
Looking for duplicates and deleting them.
In your option which way would be the most efficient way to go about this.
Thanks
Best way would be to go with excel interop if you don't want to use any third party library.
Interop works and any action can be performed which you have mentioned in your question.
Refer this link for more info: http://csharp.net-informations.com/excel/csharp-excel-tutorial.htm
PS: above link is for c# and for interop to work ms excel must be installed on the system, this can be implemented in vb.net as well.
Hope this helps.
I have used Visual Studio Tools for Office, you will have workbooks, worksheets, columns, ranges, etc. Easy to manipulate using C#.
https://msdn.microsoft.com/en-us/library/bb608603.aspx
Install this package into your project Further no need to install Excel also this is fast mothod https://www.nuget.org/packages/ExcelDataReader/
A sort of a newbie here! I just want to know is there a way to auto format the cells in excel, upon exporting it? I am using c#.net and I can't find any codes for what I am looking for. Thanks!
If you are attempting to create the excel file from scratch or edit it's xml source directly, consider using the OpenXml SDK here: http://www.microsoft.com/en-us/download/details.aspx?id=5124
If you would like an easier approach use the classes/methods provided in the Microsoft.Office.Interop.Excel namespace. Performance here is much worse and you will be required to have Office installed, but the learning curve is not nearly as steep as for OpenXml
Another option would be using EEPlus, it has everything you need including auto formatting cells and it's incredibly fast with no need to open Excel.
You can find more info here: EPPlus
Could someone help me read a simple excel worksheet in c# app? I'd like to be able to iterate each row and have a handle on each of the columns.
Thanks,
rod.
This one is the easiest method I have found:
Create Excel (.XLS and .XLSX) file from C#
The general method is to use Excel COM Interop. A quick google will find plenty of tutorials. Here's one for creating a sheet - it should point you in the direction (reading is pretty much the same).
An alternative method is to use ADO.Net. This is only really viable if your Excel sheet is well formed as a table ( ie. Database), but is easier than the interop approach.
Here is a sample using OLEDB
http://www.techiesweb.net/2009/12/reading-records-excel-file-insert-database-aspnet/
If you are going to open Excel 2007 or 2010 workbook (ooxml format), you can download Open XML SDK 2.0 for Microsoft Office (which doesn't require you to have MS office installed).
While Excel COM Interop works, it requires Excel to be installed on the client machine. If that isn't an issue then all good, but if it is you might consider looking at the Aspose.Cells library (no affiliation, just used them before). They're simple and powerful, although do carry a commercial license cost.
I've used ADO.NET and Jet in the past. Be warned that if you have columns that aren't obviously of one type you will see weird things happen. Jet tries to assign a datatype to a column based on the first several vales. The nice thing is that you can query the spreadsheet like it is a table.
What is the best way/library to read Excel 2003 and 2007 files using C#? I need to do some heavy parsing.
Do you need to parse the file, or deal with the contents?
For parsing the file, you'd better hope it's in Open Office XML format, because the previous binary version is not documented at all.
If you just need to deal with the contents, use the Office Interop libraries.
You can try SmartXLS for .Net,it support most features of excel(cell formatting,Charts,formulas,pivot tables etc),and can read/write both the excel97-2003 xls format and the excel2007 openxml format.
I would start by trying to use ADO.NET.
If that doesn't work, I used xlsio by Syncfusion.
If the data is in some kind of table format I'd suggest to try using OleDbConnection and treating the Excel sheet as another data connection. Otherwise Interop is ok if it's not on a server or anything like that.
You can use the MS Office interop assemblies (see here) to access Excel files from .NET applications.
There are a number of 3rd party tools you can use. I would avoid using the Interop libraries as they can be pretty slow. I have used Aspose.Cells before and it works pretty well. It does cost some money though.
Is there any free library for create xls files in asp.net on a server without office?
thanks
See this codeproject solution:
http://www.codeproject.com/KB/office/biffcsharp.aspx
You could also use SpreadsheetML. It is just xml so you could generate it by printing text to a file.
OfficeWriter is another third party tool that can be used for this purpose:
http://www.officewriter.com/trial
It's an API that generates/manipulates XLS/XLSX on a server without office.
It's not free but we use the Aspose Cells tool which is excellent