日期:2014-05-19  浏览次数:20344 次

[ASP.NET]较为复杂的报表如何存为word?
报表页面是自己设计的,不只是从数据库取一些数据.以前文字和表格可以自己一行一行写进去,但现在要加入图片,好像比较麻烦.不知道用哪种方式比较好?

------解决方案--------------------
建议参考一下aspose.word可能比较贵,见过别人用,不过可以解决这个问题
------解决方案--------------------
水晶报表 不可以吗?
------解决方案--------------------
http://blog.csdn.net/ranzige/archive/2007/03/22/1537323.aspx
------解决方案--------------------
Response.ContentType = "application/vnd.ms-word ";
System.IO.StringWriter sw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
this.RenderControl(hw);
Response.Write(sw.ToString());
Response.End();


这个不知道行不行 看看
------解决方案--------------------
public void Report(HttpContext hct)
{
int billId;
if (hct.Request.QueryString[ "id "] != string.Empty)
{
billId = int.Parse(hct.Request.QueryString[ "id "].ToString());
//hct.Response.Charset= "gb2312 ";
hct.Response.AppendHeader( "Content-type ", "application/vnd.ms-word ");
hct.Response.AppendHeader( "Content-Disposition ", "filename=fhBill.doc ");
using (SqlConnection conn=new SqlConnection(General.connString))
{
StoredProc Insert=new StoredProc( "UP_CREATE_FH_BILL ",(IDbConnection)conn);
Insert.AddInputParam( "@BILL_ID ",billId);
Insert.AddOutputParam( "@CUS_NAME ",20);
Insert.AddOutputParam( "@CUS_TEL ",50);
Insert.AddOutputParam( "@CUS_ADDRESS ",100);
Insert.AddOutputParam( "@PRO_INFO ",1000);
Insert.Execute();

// string temp = System.Configuration.ConfigurationSettings.AppSettings[ "AppPath "]+ "Purchase/temp/fhbill.html ";
// Encoding code = Encoding.GetEncoding( "utf8 ");
// StreamReader sr=null;
string str= " ";
// try
// {
// sr = new StreamReader(temp, code);
// str = sr.ReadToEnd(); //读取文件
// }
// catch(Exception exp)
// {
// hct.Response.Write(exp.Message);
// hct.Response.End();
// sr.Close();
// }
str= "中文 ";
// str =str.Replace( " <!--客户姓名--> ",((SqlParameter)Insert.Command.Parameters[ "@CUS_NAME "]).Value.ToString());
// str =str.Replace( " <!--地址--> ",((SqlParameter)Insert.Command.Parameters[ "@CUS_ADDRESS "]).Value.ToString());
// str =str.Replace( " <!--电话--> ",((SqlParameter)Insert.Command.Parameters[ "@CUS_TEL "]).Value.ToString());
// str =str.Replace( " <!--产品--> ",((SqlParameter)Insert.Command.Parameters[ "@PRO_INFO "]).Value.ToString());
hct.Response.Write(str+ " <br> ");
hct.Response.End();
}
}
else
{
hct.Response.Redirect( "../Purchase/OrderBillManage.aspx ");
}
}

给你个;例子
------解决方案--------------------
图片转成二进制,可以试一下