读取word文本、图片(一)编程部分

1.电脑上有office

    本地的office版本是office2013

2.添加引用

  程序集-扩展--找到“Microsoft.Office.Interop.Word”等

读取word文本、图片(一)编程部分

读取word文本、图片(一)编程部分

3.上传文件完成时,读取word内容

fineUploadInit方法中,//单个文件上传完成事件

onComplete

中写LoadReadWord(responseJSON.GUID);

修改

LoadReadWord(responseJSON.GUID, responseJSON.FileType);//传递id,文件后缀


    function LoadReadWord(Guid) {
        $.post("@Url.Action("ReadWord")",{ guid: Guid }, function (data) {
            //alert(data);
        },'Json');
    }

修改

    function LoadReadWord(Guid,FileType) {
        $.post("@Url.Action("ReadWord")",{ guid: Guid , FileType:FileType }, function (data) {
            //alert(data);
        },'Json');
    }

4.后台添加using Microsoft.Office.Interop.Word;

public string ReadWord(string guid) {}

string filePath = ConfigurationManager.AppSettings["FilePath"]+"\\"+guid+".doc";


修改

public string ReadWord(string guid , string filetype) 

string filePath = ConfigurationManager.AppSettings["FilePath"] + "\\" + guid + filetype;//".doc"