View Single Post
  #2   Report Post  
Posted to microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.aspnet,microsoft.public.excel.programming
Tim Johnson Tim Johnson is offline
external usenet poster
 
Posts: 5
Default generating Excel files w/ .NET? (an ASP.NET, C# web app)

You can use the Excel COM wrapper, but I've found it quite easy to write
Excel-XML to a file (then you don't even need Excel installed on your
server). If you name that file with an .xls extension, when you double-click
on it, it brings up Excel and gets interpreted just fine.

The trick is to build a real Excel spreadsheet the way you want then save it
as XML to see what tricks are involved in using the XML. Then just do that
in code. I just recently did this to create a spreadsheet with 3 tabs,
auto-wrapped cells,
data filters, inter-tab hyperlinks, cell highlighting, and freeze-panes.
It's all right there in the XML, you just do what they do.

Here's a good starter article:

http://msdn.microsoft.com/library/de.../odc_xmlss.asp


" wrote:

hello,

can anyone speak to some of the common or preferred methods for
building Excel .XLS files, programmatically thru the .NET framework?

i have an intranet app that needs to generate & email .xls files for
users. these are not reports, but rather more like forms. its a pretty
simple doc, two worksheets -- the first is basic info common to all
recepients. the second is a simple data table that, depending on the
recepient, contains pre-populated rows of data. there are some blank
date fields in the table for the recepient to fill in. (and yep, after
they do so and save, it will eventually get sent back to us for parsing
of the values)

i wont really get into the why's of this project, but suffice it to say
this is the workflow we need.

i had hoped i could retrieve an ADO.NET datatable of my recepient's
rows, loop thru it, and add rows/cells to an in-memory Excel doc. then
stream it out to the user or email it.

as i understand VBA was designed to do this, but i would prefer to
avoid VBA and keep it all .NET. ive found some 3rd party components to
do such a thing, but at $7,500 a CPU, they seem pretty expensive. are
there any other alternatives?


thanks!
matt