TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
narasiman rao
NA
519
766.9k
retrieving the store procedure result display into excel
Apr 23 2013 9:39 AM
Code as follows;
String Sql;
SqlDataReader Dr;
SqlDataCon Scon = new SqlDataCon();
Label1.Text = "";
try
{
if (CrsList.GetMajorCode.ToString().Trim() == null || CrsList.GetMajorCode.ToString().Trim() == "")
{
Label1.Text = "Invalid course. Course is not selected";
return;
}
if (CrsList.GetMinorCode.ToString().Trim() == null || CrsList.GetMinorCode.ToString().Trim() == "")
{
Label1.Text = "Invalid course. Course is not selected";
return;
}
if (CrsList.GetBatchDate.ToString().Trim() == null || CrsList.GetBatchDate.ToString().Trim() == "")
{
Label1.Text = "Invalid Batch. Batch is not selected";
return;
}
DataTable Dt = new DataTable();
Sql = "OH_BatchWise_Collection_Report_Psea'" + CrsList.GetBatchID.ToString().Trim() + "'";
Dr = Scon.ReadSql(Sql);
Dt.Load(Dr);
//Generating the excel
String attachment = "attachment; filename=collectiondetails.xls";
Response.ClearContent();
Response.ClearHeaders();
Response.Clear();
Response.Buffer = true;
Response.Charset = "";
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
Response.Write("");
Response.Write("");
Response.Write("<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\">");
Response.Write("<body>");
Response.Write("<table>");
Response.Write("<tr>");
Response.Write("<td colspan= 8><b><center>");
Response.Write("<Font size=4 face='Arial'>HIMT COLLEGE</font>");
Response.Write("</b></center></td>");
Response.Write("</tr>");
Response.Write("<tr>");
Response.Write("<td colspan=8><center><b><Font size=3 face='Arial'>");
Response.Write("Batch wise fee collection details- " + CrsList.GetMinorCode.ToString().Trim() + " - " + CrsList.GetBatchDate.ToString());
Response.Write("</font></b></center></td>");
Response.Write("</tr>");
Response.Write("</table>");
Response.Write("<table border=1 bordercolor=black>");
Response.Write("<tr style='height:16pt'>");
foreach (DataColumn dc in Dt.Columns)
{
Response.Write("");
}
Response.Write("");
try
{
Response.Flush();
Response.Write("</table>");
Response.Write("</body>");
Response.Write("</html>");
//Response.End();
}
catch (Exception ex1)
{
Label1.Text = ex1.ToString();
return;
}
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
catch (Exception ex1)
{
Label1.Text = ex1.ToString();
return;
}
Design page in run mode as follows;
Dropdownlist (All Course name is there)
Listbox1 Listbox2
In Listbox 1 all the sub course are present
In Listbox 2 batch date of sub course are present.
In the run mode when i select the course from the downlist, in the listbox1 subcourse are present and select the sub course from listbox1 then batchdate are present in the listbox2.
Then i click the Generate button that particular batch date of course want to show in the excel.
for that saving the data in the excel i written the code above.
But i click the Generate Button that particular batch date of course excel is not opening.
what is the problem in my above code.
from my above code what is the problem please help me.
Regards,
Rao
Reply
Answers (
0
)
The wise way to define a string class
Add text and image to link button