我必須將每個數據導出爲excel表格或ant格式,例如pdf,word等。我該怎麼做(將數據寫入任何格式)...我已經在html中顯示數據..我必須以word或任何格式導出。將每個數據導出爲excel表格或任何格式
公共無效的功能(字符串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();
}
您可以隨時使用水晶報表和導出結果集爲PDF ...查看該http://www.codeproject.com/Articles/14597/Convert-a-Crystal-Report-to- PDF或這裏這裏http://vb.net-informations.com/crystal-report/vb.net_crystal_report_export_pdf.htm – 2012-02-20 08:14:40
我知道使用水晶我可以做到這一點,但要求是以上.. – harsh 2012-02-20 08:16:46