码迷,mamicode.com
首页 > Web开发 > 详细

word转html

时间:2015-06-16 14:25:54      阅读:158      评论:0      收藏:0      [点我收藏+]

标签:

 private void E_docx(string f_o)
        {
            //BLL.MedicalTypeBLL mdl = new BLL.MedicalTypeBLL();
            //HiddenField1.Value = mdl.D_Medicals(f_o).Rows[0]["MEDICAL_TEMPLET"].ToString();
            //Microsoft.Office.Interop.Word.ApplicationClass word = new Microsoft.Office.Interop.Word.ApplicationClass();
            //Type wordType = word.GetType();
            //Microsoft.Office.Interop.Word.Documents docs = word.Documents; // 打开文件   
            //Type docsType = docs.GetType();
            //object fileName = Server.MapPath("~/UploadImgs/") + mdl.D_Medicals(f_o).Rows[0]["MEDICAL_TEMPLET"].ToString();
            //Microsoft.Office.Interop.Word.Document doc = (Microsoft.Office.Interop.Word.Document)docsType.InvokeMember("Open", System.Reflection.BindingFlags.InvokeMethod, null, docs, new Object[] { fileName, true, true }); // 转换格式,另存为   
            //Type docType = doc.GetType();
            //Encoding code = Encoding.GetEncoding("gb2312");
            //string str = DateTime.Now.ToString("yyyyMMddHHmmss");
            //fileName = str + ".htm";
            //StreamWriter sw = new StreamWriter(Server.MapPath("htm/") + fileName, false, code);
            //sw.Close();
            //object saveFileName = Server.MapPath("htm/") + fileName;
            ////保存HTML  

            //docType.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { saveFileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });
            //// 退出 Word 
            //object saveChanges = System.Reflection.Missing.Value;
            //object originalFormat = System.Reflection.Missing.Value;
            //object routeDocument = System.Reflection.Missing.Value;
            //docs.Close(ref saveChanges, ref originalFormat, ref routeDocument);
            ////doc.Close(ref saveChanges, ref originalFormat, ref routeDocument);
            //wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);

            //FileStream tFile = File.Open(saveFileName.ToString(), FileMode.Open, FileAccess.Read);
            //StreamReader sr = new StreamReader(tFile, code);
            //StringBuilder sb = new StringBuilder(sr.ReadToEnd());
            //string subs = string.Empty;
            //int iBeginIndex = sb.ToString().IndexOf("<body");
            //int  iEndIndex = sb.ToString().LastIndexOf("</body>");
            //int see = sb.ToString().Length;
            //subs = sb.ToString().Substring(iBeginIndex, iEndIndex - iBeginIndex).Replace("<body", "<div");
            //subs = sb.ToString().Replace("</body>", "</div>");
            //subs = subs.Replace(str + ".files", "htm/" + str + ".files");
            //subs = subs.Replace("v:imagedata", "image");
            //int num1 = subs.ToLower().IndexOf("<table");
            //int num2 = subs.ToLower().LastIndexOf("</table>");
            //str1 = subs.Substring(0, num1);
            //str2 = subs.Substring(num2);

            //div1.InnerHtml = subs.ToString();

        }

word转html

标签:

原文地址:http://www.cnblogs.com/110abcd/p/4580540.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!