473,396 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Excel report using asp.net

I am building an ASP.net application which will generate a formatted Excel
report.
Is there a way I can using the Excel on the client pc?
Do I have to do a full install of Excel on the server or just add the needed
dll's to my ASP.net project.

Terry
Nov 19 '05 #1
5 2989
The server doesn't need Excel...

Here's a method that sends a excel application type stream, converting a
datagrid object into a excel like table...

public static void ExportToXls(DataGrid dgExport, HttpResponse
response)
{

response.Clear();
response.Buffer = true;
response.Charset = "";
response.ContentType = "application/vnd.ms-excel";

System.IO.StringWriter stringWrite = new
System.IO.StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

ClearControls(dgExport);
dgExport.GridLines = GridLines.None;
dgExport.HeaderStyle.Font.Bold = true;
dgExport.AlternatingItemStyle.BackColor =
System.Drawing.Color.WhiteSmoke;
dgExport.HeaderStyle.ForeColor =
System.Drawing.Color.DarkBlue;
dgExport.HeaderStyle.BackColor =
System.Drawing.Color.LightGray;
dgExport.RenderControl(htmlWrite);

response.Write(stringWrite.ToString());
response.End();

}


"Terry" <te***@xxx.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am building an ASP.net application which will generate a formatted Excel
report.
Is there a way I can using the Excel on the client pc?
Do I have to do a full install of Excel on the server or just add the
needed
dll's to my ASP.net project.

Terry

Nov 19 '05 #2
I got this client-side script from Steve Orr's site
(http://steveorr.net/Articles/ExcelExport.aspx). You should read his
discussion also.

<scriptlanguage="vbscript">
Sub exportbutton_onclick
Dim sHTML, oExcel, oBook
sHTML = document.all.item("DataGrid1").outerhtml
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oExcel.Visible = true
oExcel.UserControl = true
End Sub </script>

"Terry" <te***@xxx.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am building an ASP.net application which will generate a formatted Excel
report.
Is there a way I can using the Excel on the client pc?
Do I have to do a full install of Excel on the server or just add the needed dll's to my ASP.net project.

Terry

Nov 19 '05 #3
You should not use the Excel Application object, it's not created for this
purpose. Instead, if you want to go this route you sould use the Office Web
Components downloadable from Microsoft's web site.

Access this object in this way leaves Excel instances open in memory after
the uses shut them down and causes other problems as well...
"bill" <be****@datamti.com> wrote in message
news:eE****************@TK2MSFTNGP12.phx.gbl...
I got this client-side script from Steve Orr's site
(http://steveorr.net/Articles/ExcelExport.aspx). You should read his
discussion also.

<scriptlanguage="vbscript">
Sub exportbutton_onclick
Dim sHTML, oExcel, oBook
sHTML = document.all.item("DataGrid1").outerhtml
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oExcel.Visible = true
oExcel.UserControl = true
End Sub </script>

"Terry" <te***@xxx.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am building an ASP.net application which will generate a formatted
Excel
report.
Is there a way I can using the Excel on the client pc?
Do I have to do a full install of Excel on the server or just add the

needed
dll's to my ASP.net project.

Terry


Nov 19 '05 #4
Here's another technique you can use. With the free export panel, just put
everything into the panel and have it generate the spreadsheet automatically
for you. It can also export to other applications just as easily, such as
Word and WordPerfect.
http://SteveOrr.net/articles/exportpanel.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"Terry" <te***@xxx.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am building an ASP.net application which will generate a formatted Excel
report.
Is there a way I can using the Excel on the client pc?
Do I have to do a full install of Excel on the server or just add the
needed
dll's to my ASP.net project.

Terry

Nov 19 '05 #5
Hi Bill,

What do you do when you get the "Access denied" error ? Because I don't want
to change the settings on my webserver (say that i ant to use it on another
webserver, then i have to configure that too, and that's something i don't
want to)

Thx

"bill" wrote:
I got this client-side script from Steve Orr's site
(http://steveorr.net/Articles/ExcelExport.aspx). You should read his
discussion also.

<scriptlanguage="vbscript">
Sub exportbutton_onclick
Dim sHTML, oExcel, oBook
sHTML = document.all.item("DataGrid1").outerhtml
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
oBook.HTMLProject.HTMLProjectItems("Sheet1").Text = sHTML
oBook.HTMLProject.RefreshDocument
oExcel.Visible = true
oExcel.UserControl = true
End Sub </script>

"Terry" <te***@xxx.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
I am building an ASP.net application which will generate a formatted Excel
report.
Is there a way I can using the Excel on the client pc?
Do I have to do a full install of Excel on the server or just add the

needed
dll's to my ASP.net project.

Terry


Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Spacy | last post by:
Am creating a HTML Report in asp.net. To save this report to excel on client-side, i write this code: Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition",...
1
by: Steven Stewart | last post by:
I have a user who has been using Excel for a while to keep statistics and print reports. She finds using it cumbersome because of long formulas and a lot of copying and pasting. I have designed...
6
by: Robin Cushman | last post by:
Hi all, I need some help -- I'm working with an A2K database, using DAO, and am trying to read records into a Crystal Report and then export it to a folder on our network as an Excel...
11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
4
by: somanyusernamesaretakenal | last post by:
What I am trying to achieve: Basically I have generated a report in access. This report needs to be updated using excel. (Updating the new data, not changing existing data) What I did was I...
2
by: Senthil | last post by:
Hi All I need to create an Excel report and create a command button and have to run a macro on the click event that will print all the pages in the Excel workbook. I am able to create the report...
3
by: yovation | last post by:
Hi, I have a 3 table database. 1 parent 1 child 1 child of child I would like to get the data into excel as 1 sheet (similar to a grouped report).
5
by: Sport Girl | last post by:
Hi again my great online assistants, just would like to say that i'm testing the script under unix , and after researches on the internet, i have realised that to resolve 500 Internal Server Error,...
2
hemantbasva
by: hemantbasva | last post by:
Note We need to have a template on server for generating report in multiple sheet as we do not had msoffice on server moreover this require a batch job to delete excel file created by the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.