I dint get the clear picture of the objective, as far I understand we are trying to export the data as excel right ?.
If so we can use this piece of code, which will do the simple excel download.
Excel download
Frame Work : 2.0,3.0 ,3.5,4.0
Inputs Can be: HTML Format.
HTML Format:
<html xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:excel' xmlns='http://www.w3.org/TR/REC-html40'>
<head>
<title>Name</title>
<body lang=EN-US style='mso-element:header' id=h1>
<span style='mso--code:DATE'> </span>
<div class=Section1>
***************************Mandatory Fields Starts **********************************************************************
<table align='center' border='1' bordercolor='#00aeef' width='99%' class='reporttable1' cellspacing='0' cellpadding='0' style='font-size:10;'>
<tr><td><b>Column 1</b></td> <td><b> Column 2</b></td></tr>
<tr><td><b>Data 1</b></td><td><b>Data 2</b></td></tr>
<tr><td><b> Data 3</b></td><td><b>Data 4</b></td></tr>
</table>
***************************Mandatory Fields Ends**********************************************************************
</body>
</html>
Code C#:
Response.Buffer = false;
Response.Expires = 0;
Response.Clear();
Response.ContentType = "application/vnd.ms-excel";
Response.AppendHeader("Content-Length", InputData.Length.ToString());
Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName);
Response.Write(str1.ToString());
Response.Flush();
Response.End();
Finaly : We are just writing the reponse in C# with following vlaues
1.Need to specfy the content type of the response
2.Need to give the length of the response
3.Need to tell the dispostion type as attachment to open as dailog box with [open save cancel].
Excel Download
Data Source Provider : OleDb
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + full FileName Path + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'")
;
OleDbSchemaGuid will return the Data Table.
From Data Table we can do the DB work
Lacy, if this helps please login to Mark As Answer. | Alert Moderator