文件管理 · 2022年8月20日

aspnet读取word内容|AspNet(c#)如何从数据库中读取Word并且显示到页面的NTKO Office控件内

㈠ ASP.NET 操作word文档(读写),怎么实现

展示word文件这个网上不少例子。但是写入word制定位置就是操作word文档了。1.这个隐约记得是把word文档分成好几个区域实现操作,但这个不知道具体思路。2,。如果客户允许,可是加个连接或按钮,“编辑文档”。转到文本编辑器里面。http://www.haoxiai.net/wangzhanzuo/aspnet/53267.html这里面多少有点原理。楼主看看

㈡ asp.net c# 如何读取已经存在于服务器端的word文件,并以word形式显示

在页面上拖一个Hyperlink,然后把文件的路径赋值给这个Hyperlink的navigateURL属性,就可以了.当你点hyperlink的时候,会提示你打开文件还是保存文件.属性窗口点一下navigateURL属性右边的框,可以找你要打开的文件.

㈢ aspnet2005如何对word文档进行操作

你安装完vs2005 tool for office后,在新建项目就有word模板了。。你就可以对word进行操作了。补充:首先引入类库,Microsoft.Office.Interop.Word,然后进行编程。代码如下: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.Office.Interop.Word; namespace WordTest { public partial class Form1 : Form { object strFileName; Object Nothing; Microsoft.Office.Interop.Word.Application myWordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); Document myWordDoc; string strContent = ""; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { createWord(); //openWord(); } private void createWord() { strFileName = System.Windows.Forms.Application.StartupPath + "test.doc"; if (System.IO.File.Exists((string)strFileName)) System.IO.File.Delete((string)strFileName); Object Nothing = System.Reflection.Missing.Value; myWordDoc = myWordApp.Documents.Add(ref Nothing, ref Nothing, ref Nothing, ref Nothing); #region 将数据库中读取得数据写入到word文件中 strContent = "你好\n\n\r"; myWordDoc.Paragraphs.Last.Range.Text = strContent; strContent = "这是测试程序"; myWordDoc.Paragraphs.Last.Range.Text = strContent; #endregion //将WordDoc文档对象的内容保存为DOC文档 myWordDoc.SaveAs(ref strFileName, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing, ref Nothing); //关闭WordDoc文档对象 myWordDoc.Close(ref Nothing, ref Nothing, ref Nothing); //关闭WordApp组件对象 myWordApp.Quit(ref Nothing, ref Nothing, ref Nothing); this.richTextBox1.Text = strFileName + "\r\n" + "创建成功"; } private void openWord() { fontDialog1.ShowDialog(); System.Drawing.Font font = fontDialog1.Font; object filepath = "D:\\asp.docx"; object oMissing = System.Reflection.Missing.Value; myWordDoc = myWordApp.Documents.Open(ref filepath, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing); myWordDoc.Content.Font.Size = font.Size; myWordDoc.Content.Font.Name = font.Name; myWordDoc.Save(); richTextBox1.Text = myWordDoc.Content.Text; myWordDoc.Close(ref oMissing, ref oMissing, ref oMissing); myWordApp.Quit(ref oMissing, ref oMissing, ref oMissing); } }

㈣ 您好,请问您的ASP.NET(C#)读取word,格式问题解决了吗谢谢

引用Word的Com组件Microsoft Word 11.0 Object Library,我的office2003的版本是8.3,默认安装的Office是没有这个组件的。用office盘,添加删除组件,选自定义,在Microsoft Office Word下面有.NET可编程性支持。安装。引用到项目中Web.config多了这行<compilation debug="false"><assemblies><add assembly="Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/></assemblies>程序代码:Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.ApplicationClass();//Word.ApplicationClass word = new Word.ApplicationClass();Type wordType = word.GetType();Microsoft.Office.Interop.Word.Documents docs = word.Documents;// 打开文件Type docsType = docs.GetType();object fileName = "e:\\cc.doc";Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open",System.Reflection.BindingFlags.InvokeMethod, null, (object)docs, new Object[] );// 转换格式,另存为Type docType = doc.GetType();object saveFileName = "e:\\aaa.html";//下面是Microsoft Word 9(11.0) Object Library的写法,如果是10(没试过),可能写成:/*docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,null, doc, new object[]);*////其它格式:///wdFormatHTML///wdFormatDocument///wdFormatDOSText///wdFormatDOSTextLineBreaks///wdFormatEncodedText///wdFormatRTF///wdFormatTemplate///wdFormatText///wdFormatTextLineBreaks///wdFormatUnicodeTextdocType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,null, doc, new object[] );// 退出 WordwordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,null, word, null);

㈤ ASP.NET中如何从数据库读取WORD文档,并保存在某个目录下(C#)

http://dev.csdn.net/article/52/52958.shtm建议楼主看下!绝对可以解除版你的问权题

㈥ 使用aspnet将word表单导入系统中形成web表单,在系统中完成web表单,然后将web表单再导出到word

web表单要有个东西来接收用GridDataSetOpenFileDialog openFile = new OpenFileDialog();openFile.Filter = "Excel files(*.xls)|*.xls";ExcelIO excelio = new ExcelIO();if(openFile.ShowDialog()==DialogResult.OK){ if(excelio!=null) excelio.Close(); excelio = new ExcelIO(openFile.FileName); object[,] range = excelio.GetRange(); excelio.Close(); DataSet ds = new DataSet("xlsRange"); int x = range.GetLength(0); int y = range.GetLength(1); DataTable dt = new DataTable("xlsTable"); DataRow dr; DataColumn dc; ds.Tables.Add(dt); for(int c=1; c<=y; c++) { dc = new DataColumn(); dt.Columns.Add(dc); } object[] temp = new object[y]; for(int i=1; i<=x; i++) { dr = dt.NewRow(); for(int j=1; j<=y; j++) { temp[j-1] = range[i,j]; } dr.ItemArray = temp; ds.Tables[0].Rows.Add(dr); } dataGrid1.SetDataBinding(ds,"xlsTable"); if(excelio!=null) excelio.Close();} //导出private void ExportToWord(DataTable dt, string targetWordFile) { object oMissing = System.Reflection.Missing.Value; //Start Word and create a new document. Word._Application oWord = null; Word._Document oDoc; oWord = new Word.Application(); oWord.Visible = false; oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing); //Insert a paragraph at the beginning of the document. Word.Paragraph oPara1; oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing); oPara1.Range.Text = dt.Rows[0]["mname"].ToString(); //会议名称! oPara1.Range.Font.Bold = 1; oPara1.Range.Font.Size = 18; oPara1.Range.Font.Color = Word.WdColor.wdColorRed; oWord.Selection.ParagraphFormat.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter;//水平居中 oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.oPara1.Range.InsertParagraphAfter(); object oMissing2 = System.Reflection.Missing.Value; //Insert a paragraph at the end of the document. Word.Paragraph oPara2; oPara2 = oDoc.Content.Paragraphs.Add(ref oMissing2); oPara2.Range.Text = dt.Rows[0]["datetime"].ToString(); //会议时间 oPara2.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter; oPara1.Range.Font.Color = Word.WdColor.wdColorBlack; oPara2.Range.Font.Bold = 1; oPara2.Range.Font.Size = 14; oPara2.Format.SpaceAfter = 24; oPara2.Range.InsertParagraphAfter(); int rowcount = dt.Rows.Count + 1; // 含标题行,及所有用户行 表格总行//Insert a 3 x 4 table, fill it with data, and make the first row //bold and italic. //Insert another paragraph. Word.Paragraph oPara4; oPara4 = oDoc.Content.Paragraphs.Add(ref oMissing); oPara4.Format.SpaceAfter = 24; oPara4.Range.Font.Bold = 0; oPara4.Range.Font.Size = 12; oPara4.Range.InsertParagraphAfter(); Word.Table oTable; Word.Range wrdRng = oPara4.Range;

㈦ asp.net c#怎么读取word文件并在web中显示

在页面上拖一个hyperlink,然后把文件的路径赋值给这个hyperlink的navigateurl属性,就可以了.当你点hyperlink的时候,会提示你打开文件还是保存文件.属性窗口点一下navigateurl属性右边的框,可以找你要打开的文件.

㈧ ASP.NET(C#)读取word问题

引用Word的组件Microsoft Word 11.0 Object Library,我的office2003的版本是8.3,默认安装的Office是没有这个组件的。用office盘,添加删除组件,选自定义,在Microsoft Office Word下面有.NET可编程性支持。安装。引用到项目中Web.config多了这行<compilation debug="false"><assemblies><add assembly="Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"/></assemblies>程序代码:Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.ApplicationClass();//Word.ApplicationClass word = new Word.ApplicationClass();Type wordType = word.GetType();Microsoft.Office.Interop.Word.Documents docs = word.Documents;// 打开文件Type docsType = docs.GetType();object fileName = "e:\\cc.doc";Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open",System.Reflection.BindingFlags.InvokeMethod, null, (object)docs, new Object[] { fileName, true, true });// 转换格式,另存为Type docType = doc.GetType();object saveFileName = "e:\\aaa.html";//下面是Microsoft Word 9(11.0) Object Library的写法,如果是10(没试过),可能写成:/*docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,null, doc, new object[]{saveFileName, Word.WdSaveFormat.wdFormatFilteredHTML});*////其它格式:///wdFormatHTML///wdFormatDocument///wdFormatDOSText///wdFormatDOSTextLineBreaks///wdFormatEncodedText///wdFormatRTF///wdFormatTemplate///wdFormatText///wdFormatTextLineBreaks///wdFormatUnicodeTextdocType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod,null, doc, new object[] { saveFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });// 退出 WordwordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod,null, word, null);

㈨ Asp.Net(c#)如何从数据库中读取Word并且显示到页面的NTKO Office控件内

给你一个思路,你可以让用户直接上传附件,你在服务器确定一个文件夹做目录让用户上传的文件都复制到这个文件里面。 这样就不管用户上传的什么文件, 都可以提供下载和浏览!保存:HttpFileCollection files = HttpContext.Current.Request.Files; HttpPostedFile postedFile = null; if (fileName != "") { fileExtension = System.IO.Path.GetExtension(fileName); postedFile.SaveAs(System.Web.HttpContext.Current.Request.MapPath("../Attach Files/[这里是你要保存的文件目录名,要确定好路径]") + newFileName); }这里是打开或下载: 我这里有连接数据库改了名字,你可以自己看试着修改! SystemDbOperator sysDbOperator = new SystemDbOperator(); DataSet tmpDS = sysDbOperator.Query(strSQL); if (!Util.IsNull(tmpDS)) { string strFilePath = HttpContext.Current.Request.MapPath("Attach Files/") + fileName;//路径根据实际情况而定 if (!File.Exists(strFilePath)) { strScript = "<script>alert('该文件不存在!');window.close()</script>"; ClientScript.RegisterStartupScript(this.GetType(), "提示", strScript); return; } //打开文件流读取文件DownLoadPage.aspx?FileName = " + fileName; FileStream fs = new FileStream(strFilePath, FileMode.Open); string OldFileName = tmpDS.Tables[0].Rows[0]["FileName"].ToString(); //将文件信息以字节流方式保存到数组 byte[] bytes = new byte[(int)fs.Length]; fs.Read(bytes, 0, bytes.Length); fs.Close(); //向页面输出字节流 实现下载效果 Response.ContentType = "application/octet-stream"; Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(OldFileName)); Response.BinaryWrite(bytes); Response.End();