我现在实现的是个读取上传文件的文件,类型为word文档,请我各位咋个读取里面的数据显示到aspx的页面上。还有咋个修改上传文件的名字。

解决方案 »

  1.   

    fileupload上传时内存为保存文件
     string fileName = DateTime.Now.ToString("yyyyMMddhhmmss");
    File1.PostedFile.SaveAs(“”);string Pa=page.Server.MapPath(@"../Template_temp/"+File+"");
    page.Response.AppendHeader("Content-Disposition","attachment;filename="+File+"");
    page.Response.ContentType ="application/ms-excel";  
    page.Response.WriteFile(Pa);
    page.Response.End(); 
    private string ReadWord(string path)
    {
    string str = string.Empty;
    Document myWordDoc; 
    Microsoft.Office.Interop.Word.Application myWordApp = new Microsoft.Office.Interop.Word.ApplicationClass();object filepath = path;
    object oMissing = 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);
    str = myWordDoc.Content.Text;return str;
    }