排名
                
                
                    6
                
            
                    文章
                
                
                    6
                
            
                    粉丝
                
                
                    16
                
            
                    评论
                
                
                    8
                
            
            {{item.articleTitle}}
            
    {{item.blogName}} : {{item.content}}
        
            ICP备案  :渝ICP备18016597号-1
        
        
            网站信息:2018-2025TNBLOG.NET
        
        
            技术交流:群号656732739
        
        
            联系我们:contact@tnblog.net
        
        
            公网安备:
50010702506256
        
    
50010702506256
        
        
            欢迎加群交流技术
        
    
    
    分类:
    .NET Core
可以使用库ce.office.extension,库内部会使用到NPOI
下载依赖后使用就非常简单了,可以直接转成html在页面上显示即可
word转 html
string html = ce.office.extension.WordHelper.ToHtml("word地址");excel 转 html
string html = ce.office.extension.ExcelHelper.ToHtml("excel地址")
具体转一个word示例:
public IActionResult Index()
{
    string rootpath = _webHostEnvironment.ContentRootPath;
    string html = ce.office.extension.WordHelper.ToHtml(rootpath + "/words/bb.docx");
    ViewBag.html = html;
    return View();
}前台直接按html方式输出即可:
@Html.Raw(ViewBag.html)
转换后在页面显示的效果如下:
word的标题样式,代码样式,图片都可以正常显示(图片内部是使用的base64的编码方式)
欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)
评价