Solved

Alternatives to Server side Excel manipulation for .NET

Posted on 2010-11-15
10
870 Views
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.
0
Comment
Question by:ToAoM
10 Comments
 
LVL 13

Expert Comment

by:gbanik
Comment Utility
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.
http://www.experts-exchange.com/Software/Office_Productivity/Office_Suites/MS_Office/Excel/A_3787-Understanding-Excel-File-Internals.html
0
 
LVL 17

Author Comment

by:ToAoM
Comment Utility
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...
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
Comment Utility
0
 
LVL 17

Author Comment

by:ToAoM
Comment Utility
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!
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
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.





0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 17

Author Comment

by:ToAoM
Comment Utility
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.
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
> 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).
0
 
LVL 17

Author Comment

by:ToAoM
Comment Utility
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...
0
 
LVL 28

Expert Comment

by:sybe
Comment Utility
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.


0
 
LVL 17

Author Comment

by:ToAoM
Comment Utility
@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.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now