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; Open File
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}); Convert format, Save As
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;
Save HTML
Doctype.invokemember ("SaveAs", System.Reflection.BindingFlags.InvokeMethod, NULL, doc, new object[] {savefilename, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML});
Quit 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 to HTML