repost -- asp .net / save Excel on server

  • Thread starter Thread starter mattmerc
  • Start date Start date
M

mattmerc

Hi all,

This is a repost from a week or so ago. I'll try to reformat so it is
more clear.

I am looking for something in asp .net / vb .net that will export a
datagrid to Excel, BUT will save the file on the server (not the
client). Can this be done without Excel installed on the server?

Is there a was to send the contents of a datagrid as an excel
attachment to an email. Or even embedded in the email?

If possible, the solution should not require excel to be installed on
the server and should allow formatting of the excel to make it more
readable. Specifically, I would like the longer fields to word wrap
within the cell instead of being cut off or continuously on one line.


Any help is appreciated. I don't mind doing the research and learning
how to do this, but I am coming up blank so far. Anything with Excel
turns up so many hits it is hard to read it all.


Thanks again.
 
Is your data from the datagrid stored in a dataset? I would assume so.
In that case you can create your Excel file in memory and store it
where ever you want (server, client, email).

Are you just doing a single worksheet? In that case you might just want
to create a CSV file that doesn't require Excel. If you need a more
complex workbook, then have a look at the CarlosAG ExcelWriter.

If you need more help drop me a private email.
 
I copied this from a post I made a while back. Have you considered just
changing the MIMEType of your asp.net page such that it's opened by
Excel?

Example:

<%@ Page Language="C#"%>
<script runat=server>
void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "application/vnd.ms-excel";
}
</script>
<table>
<tr>
<td><b>Column 1</b></td>
<td style="width: 300px;"><b>Column 2</b></td>
</tr>
<tr>
<td style="background-color: yellow; color:
red;">Value</td>
<td>Another Value</td>
</tr>
</table>

-Alan
 
Thanks Alan, but I do not understand how this can save a file to the
server or send an attachment with email.
 
It can't attach to an email. However, if you have control over the
server, you could save an HTML document to the server w/ an .xls
extension and write an HttpHandler that'll include the header when a
page w/ the .xls extension is requested.

-Alan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top