Мне нужно экспортировать все данные в лист Excel или формат муравья, такие как pdf, word и т. Д. экспорт в слове или любом формате.
функция public void (строка fname)
{
strhtmlcontent.Append("<div id='id1'><table align='Center' style='background-color:Silver' BORDER-COLLAPSE:collapse cellSpacing=0 rules=all border=1 width='100%'><th width=8%>FirstName</th><th width=15%>Product Name</th><th width=15%>Client Name</th><th width=10%>Amount</th><th width=15%>Activity Date</th>");
SqlConnection scon = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
scon.Open();
if (fname == "All")
{
scmd = new SqlCommand("SELECT usermaster.firstname, Product_Master.product_name, Product_Master.client_name, Product_Master.amount, Product_Master.activity_date FROM usermaster INNER JOIN Product_Master ON usermaster.product_id = Product_Master.product_id", scon);
}
else
{
scmd = new SqlCommand("SELECT usermaster.firstname, Product_Master.product_name, Product_Master.client_name, Product_Master.amount, Product_Master.activity_date FROM usermaster INNER JOIN Product_Master ON usermaster.product_id = Product_Master.product_id where firstname='"+fname+"'", scon);
}
dr = scmd.ExecuteReader();
string firstname = "", product_name = "", activity_date = "";
string client_name = "", amount = "";
while (dr.Read())
{
firstname = dr["firstname"].ToString();
product_name = dr["product_name"].ToString();
client_name = dr["client_name"].ToString();
amount = dr["amount"].ToString();
activity_date = dr["activity_date"].ToString();
strhtmlcontent.Append("<tr><td align='center'>" + firstname + " </td><td align='center'>" + product_name + " </td><td align='center'>" + client_name + " </td><td align='center'>" + amount + " </td><td align='center'>" + activity_date + " </td></tr>");
}
dr.Close();
strhtmlcontent.Append("</table></div>");
HttpContext.Current.Response.Write(strhtmlcontent);
HttpContext.Current.Response.Flush();
//HttpContext.Current.Response.End();
}