Aspose or Spreadsheet gear - c#

Among Aspose and spreadsheet gear which one is best when it comes to transferring data from database to excel and reading data in an excel sheet using C#, or is there any other better suggestion for it. This should also include applying conditional formatting, chart preparation and all excel functionality via C#.

It has been a while since I tested Aspose but can say that SpreadsheetGear has been our spreadsheet API of choice for a number of years. We have done a lot of work mapping Spreadsheet data and complex functionality to SQL databases and to web applications and back again via C# - mostly with an ASP.Net Web API 2. Most Excel native functionality is available and aspects such as conditional formatting have been recently improved in the ssgear 2017 version.
Limitations to be aware of are that Excel Macros are not accessible from the API - we use C# to do that work. You can however add Macros to .xlsm template files for client download and use.
The API is very quick with small - medium spreadsheets (< 1MB) but larger spreadsheets (> 5MB) can be slow to work with. The problem here appears to be the load / open time of the spreadsheet rather than the speed of interaction. That is a particular problem with an API application where user activity is based on discrete requests rather than a continuous session where the open spreadsheet can be maintained in memory.
Support has always be very good both here and directly from SSGear.

Related

C# - delete Excel-row wihout using the Interop namespace

I am searching a C# way to delete (empty) Excel-rows in a worksheet without using the Microsoft.Office.Interop.Excel namespace.
Found many examples with the Interop namespace like C# and excel deleting rows . But is there a way to do it without third-party-tools - only with the .NET?
Thank you for your help!
The options for working with Excel files relying only on standard .NET Framework namespaces is limited. Two possibilities come to mind. The first is "simplest", but only applicable if your main interest is in working with the content as a database. The second allows you to do pretty much "anything" with the Excel workbook, but the learning curve will be steep.
Both of these approaches are suited for working in a server environment (unlike those that require presence of the Excel application) and do not require any licenses.
You can use an OLE DB connection (ACE OLE DB provider) to communicate with the contents of an Excel workbook. It allows connecting to individual worksheets as well as named ranges. Basic SQL functionality is supported.
The file format of Excel 2007 and later versions is Office Open XML (OOXML). These files are "zip packages" containing the files (xml for the most part) that make up a workbook. So any standard tools that can work with Zip packages and XML can be used to open up an Excel workbook, edit the content, then close the workbook back up. In the .NET Framework, these would be the System.IO.Packaging (in WindowsBase.dll, usually needs to be referenced specifically) and System.XML namespaces.
The documentation for the file formats is the ECMA-376 standard (http://www.ecma-international.org/publications/standards/Ecma-376.htm). A useful on-line resource is openxmldeveloper.org.
Note that Microsoft also provides the Open XML SDK, a free download which can be distributed license-free with your solution. The Open XML SDK reduces the "learning curve" as it reduces the amount of knowledge you need about the OOXML file formats. I mention this for the sake of completeness, because I know how challenging trying to work directly with the file format is. Also, since the DLL is freely distributable and can be copied as part of your solution it might meet your requirements.
This stackoverflow post may help - it discusses some libraries that can manipulate excel without needing Office installed.
The question regards VB.NET but I believe the options discussed would work with C# too...
How to process excel file in vb.net without office installed

Excel 2007 Addin - Technology options

We have a number of .xla/.xlam Excel Addins and the time has come to migrate to something easier to version control and maintain.
I'd like to write in C# if possible and the Addins will need to do the following sorts of things:-
Provide User Defined Functions to Excel
Create and manipulate named ranges in the Excel sheet
Pull data from external sources and populate cells in the Excel sheet
Currently all this is possible and simple to do with a .xlam what are the pros/cons of moving to VSTO or creating a C# Addin (I notice VS2010 has a New Project option of creating an Excel 2007 Addin).
Are there any good sources of documentation?
Thanks
Dave
I would recommend you seriously look at Excel DNA (Free) or Addin Express (chargeable). Both provide .Net functions via the .XLL interface together with .COM to .NET interface if you need it.
Performance of both of these makes VSTO look like molasses, and installation is realtively simple.
For easy creation of performing UDFs XLDNA is VERY hard to beat.

Free solution for reading/creating/updating excel files from .NET

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)

Is there a pre-existing sulution using c# with the Excel Interops to template excel like jXLS does?

I'm looking for comments, alternative solutions and recommendations.
Background:
We currently have a CRUD app built on Websphere using the struts framework. We generate excel documents using a standalone C# application that is tied together to the web application using an ActiveX control. We pass XML that contains elements for each document. Under each document we have placeholders that contain a name and a value. The document generation application takes the name (either a cell reference or a named range) and a copy of the template from a file server. It then adds the data to all of the specified locations in the document and saves the document to the users "My Documents" folder. It then attempts to upload the documents to Documentum.
Current Problem:
One of the templates has grown to very large sizes. For the most part this is because of the amount of data that needs to be displayed. We breakdown the information into groupings. Each of these groupings needs to be able to display information for up to 20 pieces. Some of these tabs also need to display up to 100 sub elements for the pieces. Due to the current nature of the home built document generation framework, it's not possible to dynamically generate the different sections with a variable number of elements. This has recently started to cause problems with the maintenance of the template. If we need to make formatting changes, it needs to be replicated to not only every tab, but possibly for every instance within each tab.
I started to look at jXLS and it's templating abilities, but since it's java based it will be a hassle to integrate it with the c# application. The other alternatives would be to build jXLS like capabilities into our generation framework, integrate a third party library into the framework, or do the document generation on the Application server. I'd prefer to avoid reinventing the wheel, and would like to re use a library from somewhere.
I'd also like to not impact the existing work flow as much as possible. So the prefered order of solutions right now looks something like this.
1) use an Existing Library for .NET
2) Call the jXLS library from the DocumentGeneration framework.
3) Build in the templating capabilities to the Generation Framework
4) Use jXLS on the application server (Due to the way we have the process upload to Documentum)
What recommendations do you have for this?
I am not sure how much this will help you, but I have used NPOI in the past for generating XLS documents and it is quite easy to work with. NPOI is a .NET port of the Java POI, POI is used by jXLS internally.
I am not sure if it's functionality will suite your requirements, or at least be a starting point.
I've used Syncfusion's XLSIO component for excel templating along the lines of JXLS. It's .net and works pretty well, but it is a commercial product and licensing becomes expensive if you have lots of developers on the project.
If you find an open source port of JXLS do share!

Import and Export Excel - What is the best library? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
In one of our ASP.NET applications in C#, we take a certain data collection (SubSonic collection) and export it to Excel. We also want to import Excel files in a specific format. I'm looking for a library I can use for this purpose.
Requirements:
Excel 2007 files (Does Excel 2003 support over 64k rows? I need more than that.)
Does not require Excel on the server
Takes a typed collection and, if it can, tries to put numeric fields as numeric in Excel.
Works well with large files (100k to 10M) - fast enough.
Doesn't crash when exporting GUIDs!
Does not cost a crapload of money (no enterprise library like aspose). Free is always great, but can be a commercial library.
What library do you recommend? Have you used it for large quantities of data? Are there other solutions?
Right now, I am using a simple tool that generates HTML that is loaded by Excel later on, but I am losing some capabilities, plus Excel complains when we load it. I don't need to generate charts or anything like that, just export raw data.
I am thinking of flat CSV files, but Excel is a customer requirement. I can work with CSV directly, if I had a tool to convert to and from Excel. Given Excel 2007 is an xml-based (and zipped) file format, I am guessing this kind of library should be easy to find. However, what matters most to me are your comments and opinions.
EDIT: Ironically, in my opinion and following the answer with the most votes, the best Excel import&export library is no export at all. This is not the case for all scenarios, but it is for mine. XLS files support only 64k rows. XLSX supports up to 1M. The free libraries that I've tried feature bad performance (one second to load one row when you have 200k rows). I haven't tried the paid ones, as I feel they are overpriced for the value they deliver when all you need is a fast XLSX<->CSV conversion routine.
I'm going to throw my hand in for flat csv files, if only because you've got the greatest control over the code. Just make sure that you read in the rows and process them one at a time (reading the document to the end and splitting will eat up all of your memory - same with writing, stream it out).
Yes, the user will have to save-as CSV in excel before you can process it, but perhaps this limitation can be overcome by training and providing clear instructions on the page?
Finally, when you export to the customer, if you set the mime type to text/csv, Excel is usually mapped to that type so it appears to the user to be 'an Excel file'.
I discovered the Open XML SDK since my original answer. It provides strongly typed classes for spreadsheet objects, among other things, and seems to be fairly easy to work with.
I am going to use it for reports in one of my projects. Alas, version 2.0 is not supposed to get released until late 2009 or 2010.
the last version of ExcelPackage that is free under LGPL for commercial projects is, https://www.nuget.org/packages/EPPlus/4.5.3.3
If you need latest and greatest, Commercial license is available here: https://epplussoftware.com/en/LicenseOverview/
I'm still fighting with the export to excel function since my application should export some data to excel-template 2007
this project seems fine to me, and the developer is very responsive to bugs and issues.
I've been using ClosedXML and it works great!
ClosedXML makes it easier for developers to create Excel 2007/2010
files. It provides a nice object oriented way to manipulate the files
(similar to VBA) without dealing with the hassles of XML Documents. It
can be used by any .NET language like C# and Visual Basic (VB).
SpreadsheetGear for .NET reads and writes CSV / XLS / XLSX and does more.
You can see live ASP.NET samples with C# and VB source code here and download a free trial here.
Of course I think SpreadsheetGear is the best library to import / export Excel workbooks in ASP.NET - but I am biased. You can see what some of our customers say on the right hand side of this page.
Disclaimer: I own SpreadsheetGear LLC
NPOI For Excel 2003
Open Source
http://www.leniel.net/2009/07/creating-excel-spreadsheets-xls-xlsx-c.html
I've used Flexcel in the past and it was great. But this was more for programmatically creating and updating excel worksheets.
CSV export is simple, easy to implement, and fast. There is one potential issue worth noting, though.
Excel (up to 2007) does not preserve leading zeros in CSV files. This will garble ZIP codes, product ids, and other textual data containing numeric values.
There is one trick that will make Excel import the values correctly (using delimiters and prefix values with the = sign, if I remember correctly, e.g. ..,="02052",...).
If you have users who will do post-processing tasks with the CSV, they need to be aware that they need to change the format to XLS and not save the file back to CSV. If they do, leading zeros will be lost for good.
For years, I have used JExcel for this, an excellent open-source Java project. It was also .NET-able by using J# to compile it, and I have also had great success with it in this incarnation. However, recently I needed to migrate the code to native .NET to support a 64-bit IIS application in which I create Excel output. The 32-bit J# version would not load.
The code for CSharpJExcel is LGPL and is available currently at this page, while we prepare to deploy it on the JExcel SourceForge site. It will compile with VS2005 or VS2008. The examples in the original JExcel documentation will pretty well move over intact to the .NET version.
Hope it is helpful to someone out here.
I've worked with excel jetcell for a long time and can really recommend it.
http://www.devtriogroup.com/exceljetcell
Commercial product
Excel files XLS & XLSX
Based on own engine in pure net.
The following site demonstrates how to export a DataTable, DataSet or List<> into a "proper" Excel 2007 .xlsx file (rather than exporting a .csv file, and getting Excel to open it).
It uses the OpenXML libraries, so you don't need to have Excel installed on your server.
Mikes Knowledge Base - ExportToExcel
All of the source code is given, free of charge, aswell as a demo application.
It's very easy to add to your own applications, you just need to call one function, passing in an Excel filename, and your data source:
DataSet ds = CreateSampleData();
string excelFilename = "C:\\Sample.xlsx";
CreateExcelFile.CreateExcelDocument(ds, excelFilename);
Hope this helps.
Check the ExcelPackage project, it uses the Office Open XML file format of Excel 2007, it's lightweight and open source...
I've tried CSharpJExcel and wouldn't recommend it, at least not until there is some documentation available. Contrary to the developers comments it is not a straight native port.
I know this is quite late, but I feel compelled to answer xPorter (writing) and xlReader (reading) from xPortTools.Net. We tested quite a few libraries and nothing came close in the way of performance (I'm talking about writing millions of rows in seconds here). Can't say enough good things about these products!
You can use Microsoft.Jet.OLEDB.4.0
We have just identified a similar need. And I think it's important to consider the user experience.
We nearly got sidetracked along the same:
Prepare/work in spreadsheet file
Save file
Import file
Work with data in system
... workflow
Add-in Express allows you to create a button within Excel without all that tedious mucking about with VSTO. Then the workflow becomes:
Prepare/work in spreadsheet file
Import file (using button inside Excel)
Work with data in system
Have the code behind the button use the "native" Excel API (via Add-in Express) and push direct into the recipient system. You can't get much more transparent for the developer or the user. Worth considering.
There's a pretty good article and library on CodeProject by Yogesh Jagota:
Excel XML Import-Export Library
I've used it to export data from SQL queries and other data sources to Excel - works just fine for me.
Cheers
You could try the following library, it is easy enough and it is just a light wrapper over Microsoft's Open XML SDK (you can even reuse formatting, styles and even entire worksheets from secondary Excel file) :
http://officehelper.codeplex.com
Spreadsheetgear is the best commercial library we have found and are using. Our company does a lot of advanced excel import and export and Spreadsheetgear supports lots of advanced excel features far beyond anything you can do with simple CSV, and it's fast. It isn't free or very cheap though but worth it because the support is excellent. The developers will actually respond to you if you run into an issue.
How about the apache POI java library. I havent used it for Excel , but did use it for Word 2007.

Categories