word转html
以前知道word/PDF在线预览都是用aspose,但实际使用时发现aspose处理页码有问题,会丢页,今天又找了找原生的word在线预览的实现方案,小文件测试没有问题,大文件还没测试,没有找到太大的word文件。。。word中有图片会在本地生成个对应的图片文件夹,如果有朋友有大的word文件也 测测,顺便告诉我一下
using System.Web.Mvc;
using Microsoft.Office;
using Microsoft.Office.Interop.Word;
namespace WebApplication1.Controllers
{
    public class HomeController : Controller
    {
        public void Test()
        {
            Microsoft.Office.Interop.Word.ApplicationClass objWord = new ApplicationClass();
            object fltDocFormat = 10; //For filtered HTML Output
            object missing = System.Reflection.Missing.Value;
            object readOnly = false; //Open file in readOnly mode

            object isVisible = false;//The process has to be in invisible mode
            object FileName =Server.MapPath("test.docx");
            object FileToSave = Server.MapPath("test.htm");
            objWord.Documents.Open(ref FileName, ref readOnly, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing, ref missing, ref missing);
            objWord.Visible = false;
            Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;
            oDoc.SaveAs(ref FileToSave, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
            objWord.Quit(ref missing, ref missing, ref missing);
        }
    }
}

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_17255515/article/details/71057294
文章标签: .NET C# html word
个人分类: C#
想对作者说点什么? 我来说一句

java将html文件生成word文件

2017年07月28日 6.19MB 下载

没有更多推荐了,返回首页

不良信息举报

word转html

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭