hello

Wednesday, 27 June 2012

Exclereport by anil kumar aggarwal

using System;using System.Data;using System.Configuration;using System.Linq;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.HtmlControls;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Xml.Linq;///
///
<summary> Summary description for Exclereport/// </summary>public class Exclereport{

{
public Exclereport()//// TODO: Add constructor logic here//}

{





{

}

{


}


{



{

}

{


}

}

{


{

}

}


ds.Clear();


}

{





public void Excelreport(DataSet ds)HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xls");HttpContext.Current.Response.ContentType = "application/ms-excel";HttpContext.Current.Response.Write("<table border='1px'>");HttpContext.Current.Response.Write("<tr>");for (int i = 0; i < ds.Tables[0].Columns.Count; i++)HttpContext.Current.Response.Write("<td align='center' style='font-family: Calibri; font-size: 18px; font-weight: bold; color: #FFFFFF; background-color: #006699' >" + ds.Tables[0].Columns[i].ColumnName + "</td>");for (int i = 0; i < 100; i++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < ds.Tables[0].Rows.Count; i++)HttpContext.Current.Response.Write("<tr>");DataRow row = ds.Tables[0].Rows[i];for (int j = 0; j < ds.Tables[0].Columns.Count; j++)HttpContext.Current.Response.Write("<td align='left' >" + row[j] + "</td>");for (int k = 0; k < 100; k++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < 50; i++)HttpContext.Current.Response.Write("<tr>");for (int j = 0; j < 105; j++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");HttpContext.Current.Response.Write("</table>");HttpContext.Current.Response.End();public void ExcelreportHrTraining(DataSet ds)HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xls");HttpContext.Current.Response.ContentType = "application/ms-excel";HttpContext.Current.Response.Write("<table border='1px'>");HttpContext.Current.Response.Write("<tr>");//HttpContext.Current.Response.Write("<td align='center' colspan=" + ds.Tables[0].Columns.Count+1 + " style='font-family: Calibri; font-size: 18px; font-weight: bold; color: Black ;background-color: #808080; border: 0px none #808080' >For the Period : January '11 to December '11 <br/>CDP</td>");


{


}




HttpContext.Current.Response.Write("<td align='center' colspan='15' style='font-family: Calibri; font-size: 18px; font-weight: bold; color: Black ;background-color: #808080; border: 0px none #808080' >For the Period : January '11 to December '11 <br/>CDP</td>");for (int i = 0; i < 100; i++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");HttpContext.Current.Response.Write("<tr>");//for (int i = 0; i < ds.Tables[0].Columns.Count; i++)//{// HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 11px; ; color: #FFFFFF; background-color: #003366' >" + ds.Tables[0].Columns[i].ColumnName + "</td>");





HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Month</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px; font-weight: bold;color: #FFFFFF; background-color: #003366' >No of Trainings</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Planned Participants</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Actual Participants</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Training Absenteeism</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Total Training Person Days (B*C)</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Emp. Strength Month Beginning</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Emp. Strength Month End</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Avg Emp Strength</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Per Person Training Days</td>");
HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Total Training Expenses</td>");//HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Training Cost per Employee</td>");




HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Training Program Score</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Trainer Score</td>");HttpContext.Current.Response.Write("<td align='center' valign='top' style='font-family: Calibri; font-size: 13px; width:80px;font-weight: bold; color: #FFFFFF; background-color: #003366' >Overall Feedback Score</td>");//}
{


}


{





{


}

{


}

}

{


{

}

}


ds.Clear();


}

{
System.IO.
System.Web.UI.


dgGrid.DataSource = dsExport;
for (int i = 0; i < 100; i++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < ds.Tables[0].Rows.Count; i++)HttpContext.Current.Response.Write("<tr>");DataRow row = ds.Tables[0].Rows[i];for (int j = 0; j < ds.Tables[0].Columns.Count-1; j++)HttpContext.Current.Response.Write("<td align='left' >" + row[j+1] + "</td>");for (int k = 0; k < 100; k++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");for (int i = 0; i < 50; i++)HttpContext.Current.Response.Write("<tr>");for (int j = 0; j < 105; j++)HttpContext.Current.Response.Write("<td></td>");HttpContext.Current.Response.Write("</tr>");HttpContext.Current.Response.Write("</table>");HttpContext.Current.Response.End();public void exlRet(DataSet dsExport)StringWriter tw = new System.IO.StringWriter();HtmlTextWriter hw =new System.Web.UI.HtmlTextWriter(tw);DataGrid dgGrid = new DataGrid();//Report Header//hw.WriteLine("<b><u><font size='5'>" + // "Report for the Fiscal year: " + txtFY.Text + // "</font></u></b>");// hw.WriteLine("<br>&mp;nbsp;");// Get the HTML for the control.dgGrid.HeaderStyle.Font.Bold =
dgGrid.DataBind();
dgGrid.RenderControl(hw);
true;// Write the HTML back to the browser.

HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=Report.xls");HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";// this.EnableViewState = false;

}
}
HttpContext.Current.Response.Write(tw.ToString());HttpContext.Current.Response.End();

No comments:

Post a Comment