asp.net word操作 asp.net读写word文档,在vs2008调试运行的时候是正常的,在iis中运行报页面打开失败,网上查的dcomcnfg配置也都改了,请教如何解决?操作系统是xp 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 在web.config里面加上下面一行就可以了:<identity impersonate="true" userName="administrator" password="password" />但是这样相当于把administrator用户口令写在配置文件里面了,这样肯定是不好的,有其他更好的办法没有? 目录操作权限,domcnfg权限<identity impersonate="true" userName="administrator" password="password" />模拟用户错误详细信息 我直接用这个的using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.IO;using Microsoft.Office.Interop.Word;public partial class jbxx_0101 : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { //Label1.Text = Doc2Text(Request.QueryString["docFileName"].ToString()); //Label1.Text = Doc2Text("aa"); ////Response.ClearContent(); ////Response.ClearHeaders(); ////Response.ContentType = "Application/msword"; ////string s = Server.MapPath("aa.doc"); ////Response.WriteFile("aa.doc"); ////Response.Write(s); ////Response.Flush(); ////Response.Close(); #region a // ApplicationClass app = null; // Document doc = null; // object missing = System.Reflection.Missing.Value; // object FileName = Server.MapPath("编制说明.rtf");//@"E:\学习试验项目\ReadFromWordDoc\test.doc"; // object readOnly = true; // object isVisible = false; // try // { // app = new ApplicationClass(); // doc = app.Documents.Open(ref FileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, // ref missing, ref missing, ref missing); // string textString = doc.Content.Text; // Label1.Text = textString; // //Response.Write(textString); // } // catch (Exception) // { // throw; // } //} ////获得word文件的文本内容 //public string Doc2Text(string docFileName) //{ // //实例化COM // Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass(); // object fileobj = docFileName; // object nullobj = System.Reflection.Missing.Value; // //打开指定文件(不同版本的COM参数个数有差异,一般而言除第一个外都用nullobj就行了) // Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, // ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj // ); // //取得doc文件中的文本 // string outText = doc.Content.Text; // //关闭文件 // doc.Close(ref nullobj, ref nullobj, ref nullobj); // //关闭COM // wordApp.Quit(ref nullobj, ref nullobj, ref nullobj); // //返回 // return outText; #endregion }} 在使用FCKeditor时的问题 合并单元格后,TD的宽度出现差异 关于前台设计的问题 VS2005里面如何 实现页面的下载功能 数据搜索功能急!!!!!!!!!!! .NET中如何连接SYSBASE数据库 多行文本框,最多2000个汉字,使用微软拼音输入法,输入第2000个汉字时,按空格所有文字消失! 读取配置文件的原理 关于日历控件的一个小问题 使用System.Web.HttpContext.Current.Session["isSearch"]出错 是否有错 gridview的问题
<identity impersonate="true" userName="administrator" password="password" />
但是这样相当于把
administrator用户口令写在配置文件里面了,这样肯定是不好的,
有其他更好的办法没有?
<identity impersonate="true" userName="administrator" password="password" />
模拟用户
错误详细信息
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Microsoft.Office.Interop.Word;public partial class jbxx_0101 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
//Label1.Text = Doc2Text(Request.QueryString["docFileName"].ToString());
//Label1.Text = Doc2Text("aa");
////Response.ClearContent();
////Response.ClearHeaders();
////Response.ContentType = "Application/msword";
////string s = Server.MapPath("aa.doc");
////Response.WriteFile("aa.doc");
////Response.Write(s);
////Response.Flush();
////Response.Close();
#region a
// ApplicationClass app = null;
// Document doc = null;
// object missing = System.Reflection.Missing.Value;
// object FileName = Server.MapPath("编制说明.rtf");//@"E:\学习试验项目\ReadFromWordDoc\test.doc";
// object readOnly = true;
// object isVisible = false;
// try
// {
// app = new ApplicationClass();
// doc = app.Documents.Open(ref FileName, ref missing, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing,
// ref missing, ref missing, ref missing);
// string textString = doc.Content.Text;
// Label1.Text = textString;
// //Response.Write(textString);
// }
// catch (Exception)
// {
// throw;
// }
//}
////获得word文件的文本内容
//public string Doc2Text(string docFileName)
//{
// //实例化COM
// Microsoft.Office.Interop.Word.ApplicationClass wordApp = new Microsoft.Office.Interop.Word.ApplicationClass();
// object fileobj = docFileName;
// object nullobj = System.Reflection.Missing.Value;
// //打开指定文件(不同版本的COM参数个数有差异,一般而言除第一个外都用nullobj就行了)
// Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(ref fileobj, ref nullobj, ref nullobj,
// ref nullobj, ref nullobj, ref nullobj,
// ref nullobj, ref nullobj, ref nullobj,
// ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj, ref nullobj
// );
// //取得doc文件中的文本
// string outText = doc.Content.Text;
// //关闭文件
// doc.Close(ref nullobj, ref nullobj, ref nullobj);
// //关闭COM
// wordApp.Quit(ref nullobj, ref nullobj, ref nullobj);
// //返回
// return outText;
#endregion
}
}