现在做一个OA项目,事项归档时候需要生成Word文件放到 归档的文件夹里。在数据库取出一列导入word里 然后在上传到相应的文件夹里。
现在的问题是 怎么导入word文档里。 网上一搜一大堆。
测试了一下。 没一个对地。。
求正解 等待ing
现在的问题是 怎么导入word文档里。 网上一搜一大堆。
测试了一下。 没一个对地。。
求正解 等待ing
解决方案 »
- Microsoft Expression Encoder 3 安装问题
- 问一个网站SEO的问题,ASP.NET MVC网站的优化问题?
- 求助,关于js操作word插入图片
- 如何生成指定月的所有天数?
- 服务端控件调用JavaScript函数的问题??
- VS2003下打开ASP.NET应用程序出错,为什么?
- 高手请进: 求datatable 批量数据到ORACLE数据库中方法
- ascx文件里面可以包含form吗?
- 关于Response.Redirct("123.aspx?ID=变量)这里的变量怎么放?着急……
- System.Data.SqlClient.SqlException: 用户 'sa' 登录失败。
- 怎么让div里面的table边框与div的边框凑到一起?
- 麻烦了@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
直接从数据库取出来就行了啊
Try
With wrd
.Documents.Open(MapPath("template/你的模板.doc")) '打开模板
bmcount = .ActiveDocument.Books.Count
For j = bmcount To 1 Step -1
bmName = UCase(.ActiveDocument.Books.Item(j).Name)
fdname = .ActiveDocument.Books.Item(j).Name .ActiveDocument.Books.Item(j).Select()
Select Case fdname
Case "PC_ID"
.Selection.Text = pclsUser.DJTL_PC
End Select
Next
End With
wrd.ActiveDocument.Save()
berror = False
wrd.ActiveDocument.Close()
wrd.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(wrd)
wrd = Nothing
System.GC.Collect()
Catch ex As Exception
end try
public string ExportDFFK(DataSet ds,System.Web.UI.Page page,string FileName)
{
string strM="";
object nothing=System.Reflection.Missing.Value;
object optional=System.Reflection.Missing.Value;
object visible=true;
object saveChanges = true;
object NOTsaveChanges = false;
object docreadonly=true;
object originalFormat = System.Reflection.Missing.Value;
object routeDocument =System.Reflection.Missing.Value;
Word.ApplicationClass app=new Word.ApplicationClass();
object FileNa=page.Server.MapPath("../Template_temp/"+FileName);
Word.Document Doc=app.Documents.Open(ref FileNa,ref optional,ref docreadonly,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional,ref optional, ref visible);
try
{
if(Doc.Books.Exists(""))
{
object b1="SJ";
Word.Book bk1=Doc.Books.Item(ref b1); bk1.Range.Text="";
}
object strFi=page.Server.MapPath(@"../Template_temp/A.doc");
Doc.SaveAs(ref strFi,ref optional, ref optional, ref optional,ref optional, ref optional, ref optional,ref optional, ref optional, ref optional, ref optional);
Doc.Close(ref NOTsaveChanges, ref originalFormat, ref routeDocument);
app.Quit(ref NOTsaveChanges, ref originalFormat, ref routeDocument);
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
System.Runtime.InteropServices.Marshal.ReleaseComObject(Doc);
app=null;
Doc=null;
GC.Collect();
GC.Collect();
}
catch(Exception err)
{
strM=err.Message+",导出失败!";
return strM;
}
return "";
}或
添加table到word
Word.Table tb=ph.Range.Tables.AddOld(ph.Range ,1,6);
tb.Rows.Alignment=Word.WdRowAlignment.wdAlignRowCenter;
tb.Columns.Item(3).Width=150;
tb.Columns.Item(4).Width=100;
tb.Range.Font.Size=15;
tb.Range.Font.Bold=2;