C#在线预览文档(word,excel,pdf,txt,png)

本文介绍了使用C#进行文档在线预览的方法,包括将Word转为HTML预览,利用Interop组件预览Word和Excel,直接在浏览器中查看PDF、文本和图片文件。
摘要由CSDN通过智能技术生成

                           C#在线预览文档(word,excel,pdf,txt,png)

1、预览方式:将word文件转换成html文件然后预览html文件
2、预览word文件:需要引入Interop.Microsoft.Office.Interop.Word.dll(Com组件)
3、预览Excel文件:需要引入Interop.Microsoft.Office.Interop.Excel.dll(Com组件,Microsoft Excel 12.0(or other version) Object Library)
4、PDF文件直接嵌入到浏览器中进行查看,无需转换(需安装pdf阅读器)
5、文本文件直接嵌入到浏览器进行查看,无需转换

6、图片文件直接嵌入到浏览器进行查看,无需转换

Excel预览方法
using Microsoft.Office.Interop.Excel;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for ExcelPreview
/// </summary>
public class ExcelPreview
{
    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.V
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值