如何将webform导出到word文档? [英] How to export a webform into a word document?

查看:87
本文介绍了如何将webform导出到word文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将asp.net中的webform或页面转换为word文档?我有需要打印和签名的计算。有没有我可以使用的简单代码?

解决方案

看看这篇文章

http://helpingpeoples.blogspot.co.uk/2008/03/export-aspnet- page-to-word-excel-or-pdf.html [ ^ ]或

http://www.notesfor.net/post/2009/08/20/Generate-a-docx-from-AspNet- page.aspx [ ^ ]


嗨...



从数据库读取数据到word -document,看到这个代码。



按钮事件:

/ /打开数据库连接

con = new MySqlConnection(cs);

cmd = new MySqlCommand(select * from files,con);

con.Open();

da = new MySqlDataAdapter(cmd);

DataSet ds = new DataSet();

da.Fill(ds);

con.Close();

//从floder中读取文件

string path = Server.MapPath(〜/ PDF /+ ds.Tables [0]。行[0] [FileName]。ToString());

WebClient客户端=新WebClient();

Byte [] buffer = client.DownloadData(path) ;



if(buffer!= null)

{

Response.ContentType =application / msword ;

Response.AddHeader(content-length,buffer.Length.ToString());

Response.BinaryWrite(缓冲区);

}



可能对你有帮助。

How can I convert my webform or page in asp.net to a word document? I have calculations that needs to be printed out and signed. Is there a simple code I could use?

解决方案

Have a look at this article
http://helpingpeoples.blogspot.co.uk/2008/03/export-aspnet-page-to-word-excel-or-pdf.html[^] or
http://www.notesfor.net/post/2009/08/20/Generate-a-docx-from-AspNet-page.aspx[^]


Hi...

read data from database to word-document,see this code.

in button event:
//Open the database connection
con = new MySqlConnection(cs);
cmd = new MySqlCommand("select * from files", con);
con.Open();
da = new MySqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
con.Close();
// Read the file from floder
string path = Server.MapPath("~/PDF/" + ds.Tables[0].Rows[0]["FileName"].ToString());
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);

if (buffer != null)
{
Response.ContentType = "application/msword";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}

may its helpful to u.thank u.


这篇关于如何将webform导出到word文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆