473,548 Members | 2,593 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

What methods can export excel file from stored procedure with parameters which input from web form?

ABC
What methods can export excel file from stored procedure with parameters
which input from web form?


Mar 28 '06 #1
3 2585
You're going to have to do a lot of this yourself - there's nothing
built into the Frawework to support this althought here are many third
party components that can help with creating Excel files

I've used the Microsoft.Offic e.Interop.Excel namespace inside
Microsoft.Offic e.Interop.Excel .dll.
You'll need to download and install Office Primary Interop Assemblies.
See
http://msdn.microsoft.com/library/de...dc_oxppias.asp

I've used it in a Windows app to open Excel and write to cells.

The trouble is these aren't meant to be used as server side components.
Office 2006 contains Excel object model that is decoupled from the UI
and intended for server-side use.

Mar 28 '06 #2
one method to do it...

bring the parametrized data back into a datagrid and add a 'save to excel'
button on your form

the following code in your webform:
(you have to use your own datagrid's name in the top btnExportToExce l_Click,
the ClearControl method takes out troublesome controls from the datagrid (in
memory) and when it's done it calls the datagrid's RenderControl Method, a
File save as dialog is thrown up and you're there)

if your dataset is too large, this might not be an ideal method, but it
works fine for exporting datagrid data from a web page

private void btnExportToExce l_Click(object sender, System.EventArg s e)
{
//export to excel

Response.Clear( );
Response.Buffer = true;
Response.Conten tType = "applicatio n/vnd.ms-excel";
Response.Charse t = "";
this.EnableView State = false;

System.IO.Strin gWriter oStringWriter = new System.IO.Strin gWriter();
System.Web.UI.H tmlTextWriter oHtmlTextWriter = new
System.Web.UI.H tmlTextWriter(o StringWriter);

this.ClearContr ols([enter your datagrid's name here]);
[Enter your datagrid's name here].RenderControl( oHtmlTextWriter );

Response.Write( oStringWriter.T oString());

Response.End();

}

private void ClearControls(C ontrol control)
{
for (int i=control.Contr ols.Count -1; i>=0; i--)
{
ClearControls(c ontrol.Controls[i]);
}

if (!(control is TableCell))
{
if (control.GetTyp e().GetProperty ("SelectedItem" ) != null)
{
LiteralControl literal = new LiteralControl( );
control.Parent. Controls.Add(li teral);
try
{
literal.Text =
(string)control .GetType().GetP roperty("Select edItem").GetVal ue(control,null );
}
catch
{
}
control.Parent. Controls.Remove (control);
}
else
if (control.GetTyp e().GetProperty ("Text") != null)
{
LiteralControl literal = new LiteralControl( );
control.Parent. Controls.Add(li teral);
literal.Text =
(string)control .GetType().GetP roperty("Text") .GetValue(contr ol,null);
control.Parent. Controls.Remove (control);
}
}
return;
}
good luck
CharlesA

Mar 28 '06 #3
There are a variety of ways to export data to Excel, most of which are
detailed here:
http://SteveOrr.net/articles/ExcelExport.aspx

If you want a more automatic approach, you might try one of these
components:
http://SteveOrr.net/articles/ExportPanel.aspx
http://SteveOrr.net/reviews/AsposeExcel.aspx
http://SteveOrr.net/reviews/OfficeWriter.aspx

You could also consider Crystal Reports or the new VSTO:
http://msdn.microsoft.com/office/understanding/vsto/

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"ABC" <ab*@abc.com> wrote in message
news:Oa******** ******@TK2MSFTN GP10.phx.gbl...
What methods can export excel file from stored procedure with parameters
which input from web form?

Mar 29 '06 #4

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

Similar topics

3
22105
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due...
1
5013
by: Matt | last post by:
I have an ASP page that calls ASP routines that I created that execute a database query and return the results to a recordset. I then iterate through the recordset and display the data in a table. Before I iterate through the recordset I instruct the browser that the content type is Excel using the following line: (Response.ContentType =...
8
9840
by: Mark Flippin | last post by:
This is for a reporting problem using: Access 2000 SQL Server 2000 Both at SP3 I've a stored procedure in SQL Server 2000 which builds a result set from a disparate set of tables, utilizing a temp table. The procedure takes two parameters to specify the criteria on selecting the table information for inclusion in the result set, builds...
2
5257
by: Bob | last post by:
I'm new to Access projects and SQL server and am not a veteran VB programmer. There's a cry for help! I'm attempting to print the current form on screen by using a command button which the user clicks once they have selected the desired record. The button calls a report which uses a stored procedure as its record source. The SP has 2 input...
1
962
by: Johnny | last post by:
I have a stored procedure that takes three input parameters and returns a single record result set. The stored procedure is declare as follows: p_getTaxAmount (@ZipCodeDtlId uniqueidentifier, @CategoryID uniqueidentifier, @SalesAmount decimal(17,8)) I have a windows form where the user enters the zip code, category, and sales amount. I...
3
1760
by: Bilbo | last post by:
I have a a headscratcher here: I have a form that when submitted should do 2 things when a user enters data and then clicks the Add button. Here goes: 1. Call a stored procedure called AddCompany to insert the company name from the Company Name textbox into the COMPANY table and return the @@IDENTITY of the company name just input into the...
0
1270
by: Vadim Vulfov | last post by:
My task was to create Crystal Report on ASP.NET page to display different date depending on to textboxes From Date and To Date. I created stored procedure in SQL with two parameters from_date and to_date. I created dataset object in ASP.NET (drag and drop on it the stored procedure I just created) and save as XSD file. In the Crystal...
4
14995
by: Jiro Hidaka | last post by:
Hello, I would like to know of a fast way to export data source data into an Excel sheet. I found a way from C# Corner(Query Tool to Excel using C# and .NET) which is a neat little way of exporting dataset data to an excel using the Excel COM object. This works fine but the problem is its pretty darn slow when exporting large
2
4086
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
7707
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3495
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3475
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1926
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
751
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.