因为权限原因,我需要只打开而不下载,只在客户端显示文件(word,excel,ppt,txt),在网上找了一天都没找到解决的办法,所有的方法都是打开和下载同时存在,有没有什么方法可以只打开文件而不可下载的,只要把文件内容在客户端显示出来就行,最好可提供源代码(C#),请各位大哥帮帮忙了
-------------------------------------------------
做个ActiveX控件或JavaBean
-------------------------------------------------
我试过excel的:
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + filename + "';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(mystring);
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
this.dtgShow.DataSource = myDs.Tables[0];
this.dtgShow.DataBind();
但是报错啊,说sheet1$不存在
-------------------------------------------------
下面的是读WORD的文件内容:
private void Button1_Click(object sender, System.EventArgs e)
{
string strError = "";
Word.Document wDoc=null;
Word.Application wApp=null;
object missing=System.Reflection.Missing.Value;
CreateWordDocument(@"F:/新建文件夹/123.doc",ref wDoc,ref wApp,ref strError);
string str = strError;
TextBox1.Text=wDoc.Content.Text;
}
public static void CreateWordDocument(string FileName, ref Word.Document wDoc,ref Word.Application WApp,ref string strError)
{
if(FileName=="") return;
Word.Document thisDocument=null;
Word.FormFields formFields=null;
Word.ApplicationClass thisApplication=new Word.ApplicationClass();
thisApplication.Visible=true;
thisApplication.Caption="";
thisApplication.Options.CheckSpellingAsYouType=false;
thisApplication.Options.CheckGrammarAsYouType=false;
Object filename=FileName;
Object ConfirmConversions=false;
Object ReadOnly=true;//true;
Object AddToRecentFiles=false;
Object PasswordDocument = System.Type.Missing;
Object PasswordTemplate = System.Type.Missing;
Object Revert = System.Type.Missing;
Object WritePasswordDocument = System.Type.Missing;
Object WritePasswordTemplate = System.Type.Missing;
Object Format = System.Type.Missing;
Object Encoding = System.Type.Missing;
Object Visible = System.Type.Missing;
Object OpenAndRepair = System.Type.Missing;
Object DocumentDirection = System.Type.Missing;
Object NoEncodingDialog = System.Type.Missing;
Object XMLTransform = System.Type.Missing;
object missing=System.Reflection.Missing.Value;
try
{
Word.Document wordDoc =
thisApplication.Documents.Open(ref filename, ref ConfirmConversions,
ref ReadOnly, ref AddToRecentFiles, ref PasswordDocument, ref PasswordTemplate,
ref Revert,ref WritePasswordDocument, ref WritePasswordTemplate, ref Format,
ref Encoding, ref Visible, ref OpenAndRepair, ref DocumentDirection,
ref NoEncodingDialog );//, ref XMLTransform
thisDocument = wordDoc;
wDoc = wordDoc;
WApp = thisApplication;
formFields = wordDoc.FormFields;
}
catch(Exception ex)
{
strError=ex.Message;
throw new Exception("操作word时出现异常!");
}
-------------------------------------------------
ASP.NET 未被授权访问所请求的资源。请考虑授予 ASP.NET 请求标识访问此资源的权限。ASP.NET 有一个在应用程序没有模拟时使用的基进程标识(通常,在 IIS 5 上为 {MACHINE}/ASPNET,在 IIS 6 上为网络服务)。如果应用程序正在通过 <identity impersonate="true"/> 模拟,则标识将为匿名用户(通常为 IUSR_MACHINENAME)或经过身份验证的请求用户。
权限的问题该怎么解决啊
-------------------------------------------------