Alternatives to Server side Excel manipulation for .NET

Posted on 2010-11-15
Medium Priority
Last Modified: 2012-05-10
I'm looking for a viable alternative to Excel automation to manipulate, read and create excel files in an ASP.NET website context.

I'm aware of a couple of component builders that support these scenario's:
- Aspose Cells,
- softartisans OfficeWriter
- Spreadsheetgear

But these all have one thing in common, they're very expensive.

I'd prefer a solution that supports both Office 2003 file formats and Office 2007 file formats, but a good solution that only supports either, is no problem for me.

I've also found a few links to System.IO.Packaging, but I haven't been able to find a good tutorial that shows how to create and manipulate excel files, other than through complex XML manipulation.
Question by:Jesse Houwing
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 13

Expert Comment

ID: 34135028
If you are ready to invest some time, there is a very intriguing direction. Excel files can be read and written (including all formatting and formulas) using XML. Every Excel file is actually made up of numerous XML files clubbed together to get the final effect - One Excel file. You can read these XML files directly as well as write to them. You dont need the Excel application at all. Just a thorough understanding of the Excel file Internals should be enough. I have seen a very big enterprise application built on this concept which is currently running in a multi-user (500+ users) multi-location environment (3 continents - 8 locations). It has an "generic Excel engine" that can read and write Excel file and sync with a standard database.

Here is an article to start a thought.
LVL 17

Author Comment

by:Jesse Houwing
ID: 34135084
This is what System.IO.Packaging tries to make simpler, but as I need a less experience developer to build this, I'll need more than just free XML access as the solution...
LVL 70

Accepted Solution

Éric Moreau earned 2000 total points
ID: 34135118
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

LVL 17

Author Comment

by:Jesse Houwing
ID: 34135479
I'm a big fan of Aspose too, but there is no budget in this project for their wonderful components. I feel we should just buy an enterprise license and be done with it, but that's me.

I'll have a look at ExcelPackage, it looks like it might suit our needs perfectly!
LVL 28

Expert Comment

ID: 34135955
It really depends how complicated the Excel is.

Simple solution is to send a HTML-table with content-type "application/vnd.ms-excel" and it will open in Excel on the client machine. But this allows only a single worksheet.

Then there is the single-XML-approach. Office-XML is a special XML-format which can contain many Excel features. It can create multiple worksheets in a file and it really isn't that difficult. You can take a desired Excel file and do "save as XML" to get an example of what it looks like. Don't be overwhelmed by the <styles> section, it seems that excel creates a seperate style tag for every single cell (a big overkill). I use XSLT and XML to create Excel files on the fly this way. Disadvantage is this does not support all features in Excel.

> other than through complex XML manipulation

Not sure how experienced you are with XML, but it really isn't that complicated once you are used to it.

LVL 17

Author Comment

by:Jesse Houwing
ID: 34136647
Multiple worksheets is a requirement I have to deal with, so save as HTML is no option. We also need to read the data back in, where HTML is far from ideal.

I know the XML manipulation isn't that difficult, but its a lot less readable than a few lines of code doing a transfer of data from a database to an object. The source of our data is already in objects (from Linq to Sql).

When doing XML translations we also bumped into issues with merged cells, and objects such as graphs and other things already in the workbook. When you're always creating the files from scratch and don't have to read them back in, your solution sounds ideal, but as we're having to roundtrip them, I'm first going to give ExcelPackage a try.
LVL 28

Expert Comment

ID: 34143174
> objects such as graphs and other things already in the workbook

You mean you do not start from scratch? if you have things "already in the workbook".

That makes it all so much easier. Create a connection to your not-from-scratch excel file, and use that connection to fill the workbook from your datasource (for which you need a different connection of course).
LVL 17

Author Comment

by:Jesse Houwing
ID: 34143701
We need to support both scenario's, in fact we need
- to create excel files from scratch
- read these (and similar excel files)
- manipulate existing (either from this app, but also user created) excel files

We also need these to be able to work concurrently and in an ASP.NET context. Which makes OleDb connections to Excel a less than ideal solution, unfortunately...
LVL 28

Expert Comment

ID: 34144604
It is not very clear what it is that you want. It sounds like you need a desktop application, not a web-based.

> to create excel files from scratch
Actually there is not a real difference between creating excel files from scratch and using an empty excel file to start from. In both cases you'll probably need a limited number of templates. If you want users to design their excel totally freely, you need something like google docs.

> read these (and similar excel files)
Users can not "read" excel files on the server. They can download them.

> manipulate existing (either from this app, but also user created) excel files
Same issue: users can not manipulate excel files on the server through http. They can be downloaded, edited and uploaded again. For that you do not need anything special apart from download and upload of files.

LVL 17

Author Comment

by:Jesse Houwing
ID: 34145304
@emoreau we actually are using ExcelPackagePlus, the continuation of ExcelPackage
It can be found here: http://epplus.codeplex.com/

@sybe, I wasn't talking about users reading them, its actually code doing the reading, doing some manipulations, updating values, changing references and such and then writing the whole thing into a database. I'm pretty sure of what I need. And I'm very happy with the answer provided by emoreau.

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question