日韩欧美人妻无码精品白浆,夜夜嗨AV免费入口,国产欧美官网在线看,高校回应聋哑女生因长相完美被质疑

LOGO OA教程 ERP教程 模切知識(shí)交流 PMS教程 CRM教程 開發(fā)文檔 其他文檔  
 
網(wǎng)站管理員

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

admin
2018年1月2日 21:46 本文熱度 6822

1.功能說明

輸入文件路徑,在瀏覽器輸出文件預(yù)覽信息,經(jīng)測試360極速(Chrome)、IE9/10、Firefox通過

2.分類文件及代碼說明

DemoFiles 存放可測試文件

Default.aspx  啟動(dòng)頁

ExcelPreview.cs  Excel預(yù)覽類

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
public static void Priview(System.Web.UI.Page p, string inFilePath, string outDirPath = "")
 {
 Microsoft.Office.Interop.Excel.Application 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
2
3
4
5
6
7
8
public static void Priview(System.Web.UI.Page p, string inFilePath)
 {
 p.Response.ContentType = "Application/pdf";
 string fileName = inFilePath.Substring(inFilePath.LastIndexOf(''\\'') + 1);
 p.Response.AddHeader("content-disposition", "filename=" + fileName);
 p.Response.WriteFile(inFilePath);
 p.Response.End();
 }

5.TextFilePreview.cs  文本文件預(yù)覽類

1
2
3
4
5
6
7
8
9
public static void Preview(System.Web.UI.Page p, string inFilePath)
{
string fileName = inFilePath.Substring(inFilePath.LastIndexOf(''\\'') + 1);
p.Response.ContentType = "text/plain";
p.Response.ContentEncoding = System.Text.Encoding.UTF8; //保持和文件的編碼格式一致
p.Response.AddHeader("content-disposition", "filename=" + fileName);
p.Response.WriteFile(inFilePath);
p.Response.End();
}

6. WordPreview.cs  Word預(yù)覽類

7.Readme.txt  說明了基本功能及引用Com組件的方法(首先需要安裝office),需引入的組件包括

  Microsoft Word 15.0
  Microsoft Excel 15.0

  預(yù)覽效果

1、Word

2、Excel 

3、Pdf

4、Txt

未解決的問題

Pdf、txt文件只能在當(dāng)前頁顯示,并導(dǎo)致后退鍵無效,請(qǐng)各位幫忙解決此兩種文件和doc、xls一樣在新的tab中打開

5.源碼下載
附件:
FilePreviewInBrowser_jb51.rar

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

原文鏈接:http://www.cnblogs.com/gossip/p/3473024.html


該文章在 2018/1/2 21:46:39 編輯過
關(guān)鍵字查詢
相關(guān)文章
正在查詢...
點(diǎn)晴ERP是一款針對(duì)中小制造業(yè)的專業(yè)生產(chǎn)管理軟件系統(tǒng),系統(tǒng)成熟度和易用性得到了國內(nèi)大量中小企業(yè)的青睞。
點(diǎn)晴PMS碼頭管理系統(tǒng)主要針對(duì)港口碼頭集裝箱與散貨日常運(yùn)作、調(diào)度、堆場、車隊(duì)、財(cái)務(wù)費(fèi)用、相關(guān)報(bào)表等業(yè)務(wù)管理,結(jié)合碼頭的業(yè)務(wù)特點(diǎn),圍繞調(diào)度、堆場作業(yè)而開發(fā)的。集技術(shù)的先進(jìn)性、管理的有效性于一體,是物流碼頭及其他港口類企業(yè)的高效ERP管理信息系統(tǒng)。
點(diǎn)晴WMS倉儲(chǔ)管理系統(tǒng)提供了貨物產(chǎn)品管理,銷售管理,采購管理,倉儲(chǔ)管理,倉庫管理,保質(zhì)期管理,貨位管理,庫位管理,生產(chǎn)管理,WMS管理系統(tǒng),標(biāo)簽打印,條形碼,二維碼管理,批號(hào)管理軟件。
點(diǎn)晴免費(fèi)OA是一款軟件和通用服務(wù)都免費(fèi),不限功能、不限時(shí)間、不限用戶的免費(fèi)OA協(xié)同辦公管理系統(tǒng)。
Copyright 2010-2025 ClickSun All Rights Reserved