免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
Asp.net實(shí)現(xiàn)直接在瀏覽器預(yù)覽Word、Excel、PDF、Txt文件(附源碼)

Asp.net實(shí)現(xiàn)直接在瀏覽器預(yù)覽Word、Excel、PDF、Txt文件(附源碼)

 
    1. 功能說明 輸入文件路徑,在瀏覽器輸出文件預(yù)覽信息,經(jīng)測試360極速(Chrome)、IE9/10、Firefox通過 分類文件及代碼說明  DemoFiles 存放可測試文件 Default.aspx  啟動(dòng)頁
       
    2. ExcelPreview.cs  Excel預(yù)覽類 
    3.  public static void Priview(System.Web.UI.Page p, string inFilePath, string outDirPath = '')excel = null;
              Microsoft.Office.Interop.Excel.Workbook xls = null;
              excel = new Microsoft.Office.Interop.Excel.Application();
              object missing = Type.Missing;
              object trueObject = true;
              excel.Visible = false;
              excel.DisplayAlerts = false;
              string randomName = DateTime.Now.Ticks.ToString();  //output fileName
              xls = excel.Workbooks.Open(inFilePath, missing, trueObject, missing,
                                          missing, missing, missing, missing, missing, missing, missing, missing,
                                          missing, missing, missing);
              //Save Excel to Html
              object format = Microsoft.Office.Interop.Excel.XlFileFormat.xlHtml;
              Workbook wsCurrent = xls;//(Workbook)wsEnumerator.Current;
              String outputFile = outDirPath + randomName + '.html';
              wsCurrent.SaveAs(outputFile, format, missing, missing, missing,
                                missing, XlSaveAsAccessMode.xlNoChange, missing,
                                missing, missing, missing, missing);
              excel.Quit();
              //Open generated Html
              Process process = new Process();
              process.StartInfo.UseShellExecute = true;
              process.StartInfo.FileName = outputFile;
              process.Start();
          }         

    4.   PDfPreview.cs   Pdf預(yù)覽類  
       
      1.public static void Priview(System.Web.UI.Page p, string inFilePath)
      2.    {
      3.        p.Response.ContentType = 'Application/pdf';
      4.        string fileName = inFilePath.Substring(inFilePath.LastIndexOf('') + 1);
      5.        p.Response.AddHeader('content-disposition', 'filename=' + fileName);
      6.        p.Response.WriteFile(inFilePath);
      7.        p.Response.End();
      8.    }
      TextFilePreview.cs  文本文件預(yù)覽類    
      01.public static void Preview(System.Web.UI.Page p, string inFilePath)
      02.    {
      03.        string fileName = inFilePath.Substring(inFilePath.LastIndexOf('') + 1);
      04.        p.Response.ContentType = 'text/plain';
      05.        p.Response.ContentEncoding = System.Text.Encoding.UTF8;  //保持和文件的編碼格式一致
      06.        p.Response.AddHeader('content-disposition', 'filename=' + fileName);
      07.        p.Response.WriteFile(inFilePath);
      08.        p.Response.End();
      09.    }
      WordPreview.cs  Word預(yù)覽類 Readme.txt  說明了基本功能及引用Com組件的方法(首先需要安裝office),需引入的組件包括 Microsoft Word 15.0 Microsoft Excel 15.0
      預(yù)覽效果
      1、Word 

      2、Excel 

      3、Pdf 

      4、Txt
    5.  
    6. 未解決的問題 Pdf、txt文件只能在當(dāng)前頁顯示,并導(dǎo)致后退鍵無效,請(qǐng)各位幫忙解決此兩種文件和doc、xls一樣在新的tab中打開
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
預(yù)覽有乾坤 詳解Win7的“預(yù)覽窗格”
收藏!word、excel、ppt、pdf之間這樣可完美轉(zhuǎn)換
一鍵對(duì)PDF、Excel、Word、TXT格式進(jìn)行互換,這些你都會(huì)嗎?
PDF轉(zhuǎn)換工具
只要有手機(jī),簡單幾步就能將PDF轉(zhuǎn)Word、Excel、PPT、TXT!
教你把PDF文件怎么轉(zhuǎn)換成Word!讓你的PDF、WORD、PPT、TXT之間相互轉(zhuǎn)換!需要的趕緊收了!
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服