标签:
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();
}
标签:
原文地址:http://www.cnblogs.com/110abcd/p/4580540.html