c# 把数据库中数据输出到word中

初学,但是要交作业,谁能给我一段能用的代码,我对C#不太懂
qq:445276858
最新回答
習慣了伱的虛情假意

2025-06-21 05:23:56

http://www.pudn.com/detail.asp?id=581777

SharpWord for .Net是一款功能强大,可自由读写编辑Microsoft Word 2003/2007文件类库,具有丰富的Word文档内容编辑及导入/导出功能。简单、方便、易用,可以大大提高工作效率。 ★编辑功能:等同于Word内容编辑功能,如字体、字号、颜色等 ★表格功能:等同于Word表格生成及设置 ★数据库支持:将SQL、Access数据库内容支持导出为Word表格或文档 ★丰富的模板支持:200多个word模板,方便,快捷 ★批量操作功能:将多个文档内容根据需求成批查找、替换,合并等 ★属性设置,如页面设置,安全设置、文档属性设置等. (2008-11-17, CSharp, 2385KB, 0次)

http://www.pudn.com/detail.asp?id=216222

利用VB把图片插入SQLServer数据库,并将数据库中的数据和图片导出到Word中(word中使用宏录制) (2006-09-26, Visual Basic, 137KB, 100次)
空城仅有旧梦在

2025-06-21 20:25:34

你总该自己搞懂怎么连接数据库吧。要不给你代码代码也没用。
怕黑却很晚睡的菇凉安好

2025-06-21 09:29:10

可以用CrystalReport报表
萌音草莓

2025-06-21 08:08:51

对文件的操作用io流
参考代码:
//把table控件中的数据保存到excel或word
public void Save(System.Web.UI.Control source, DocumentType type)

{
Response.Clear();
Response.Buffer= true;

//设置Http的头信息,编码格式
if (type == DocumentType.Excel)
{
//Excel
Response.AppendHeader("Content-Disposition","attachment;filename=result.xls");
Response.ContentType = "application/ms-excel";
}
else if (type == DocumentType.Word)
{
//Word
Response.AppendHeader("Content-Disposition","attachment;filename=result.doc");
Response.ContentType = "application/ms-word";
}

//设置编码
Response.Charset="GB2312";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");

//关闭控件的视图状态
source.EnableViewState =false;

//初始化HtmlWriter
System.IO.StringWriter writer = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(writer);
source.RenderControl(htmlWriter);

//输出
Response.Write(writer.ToString());

Response.End();
}