troubleshooting Question

How do I save a Table generated using ASP.net into an Excel File?

Avatar of praneethkavula
praneethkavulaFlag for India asked on
C#Microsoft ExcelASP.NET
3 Comments1 Solution195 ViewsLast Modified:
I am generating a formatted table in the form of HTML to add that in a panel, this was working fine to display the table in the required format.

No my requirement is to save the formatted table in a excel file in the server and send that as an email attachment.

My requirement is to save the table in a excel file programatically and send that file as an email attachment

Thanks...

Table tblDailyDetailPayrollReport = ddReport.createReport();
if(tblDailyDetailPayrollReport != null)
{
       pnlReport.Controls.Add(tblDailyDetailPayrollReport);
        try
	{
		string sTableStart = @"<HTML><BODY><TABLE Border=1>";
		string sTableEnd = @"</TABLE></BODY></HTML>"; 					
		StringBuilder sTableData = new StringBuilder();
		for(int iRows = 0 ; iRows < tblDailyDetailPayrollReport.Rows.Count ; iRows++)
		{
			sTableData.Append(@"<tr>");
			for(int iCols = 0; iCols < tblDailyDetailPayrollReport.Rows[iRows].Cells.Count; iCols++) 
			{
				sTableData.Append(@"<td>");
				sTableData.Append(tblDailyDetailPayrollReport.Rows[iRows].Cells[iCols].Text);
				sTableData.Append(@"</td>");
			}
			sTableData.Append(@"</tr>");
		}					
        string sTable = sTableStart + sTableData.ToString() + sTableEnd;
}
ASKER CERTIFIED SOLUTION
praneethkavula

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros