C# wordת»»³ÉHTML
C# wordת»»³ÉHTML
Ìí¼ÓcomÒýÓÃMicrosoft word 11.0 Object Library
Ìí¼Óusing System.Threading;using System.IO;
//ʵÀý»¯Ò»¸öWord
Microsoft.Office.Interop.Word.ApplicationClass appclass = new Microsoft.Office.Interop.Word.ApplicationClass();
Type wordtype = appclass.GetType();
Microsoft.Office.Interop.Word.Documents docs = appclass.Documents;//»ñÈ¡Document
Type docstype = docs.GetType();
object filename = @"E:\AA.doc";//WordÎļþµÄ·¾¶
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();
object savefilename = @"E:\bb.html";//Éú³ÉHTMLµÄ·¾¶ºÍÃû×Ó
doctype.InvokeMember("SaveAs", System.Reflection.BindingFlags.InvokeMethod, null, doc, new object[] { savefilename, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML });//Áí´æÎªHtml¸ñʽ
wordtype.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, appclass, null);//Í˳ö
Thread.Sleep(3000);//ΪÁËʹÍ˳öÍêÈ«£¬ÕâÀï×èÈû3Ãë
StreamReader objreader = new StreamReader(savefilename.ToString(), System.Text.Encoding.GetEncoding("GB2312"));
//ÒÔÏÂÄÚÈÝÊÇΪÁËÔÚHtmlÖмÓÈë¶Ô±¾ÉíWordÎļþµÄÏÂÔØ
 
Ïà¹ØÎĵµ£º
ת×Ô: http://www.cnblogs.com/rentj1/archive/2009/02/23/1396187.html
1 н¨Àà¿âMyTestDLL
2 ÓÒ»÷ÏîÄ¿“MyTestDLL”-¡·ÊôÐÔ-¡·Éú³É-¡·¹´Ñ¡“ΪCOM»¥²Ù×÷×¢²á”
3 ´ò¿ª AssemblyInfo.cs Îļþ ÐÞ¸Ä [assembly: ComVisible(true)]
4 ´ò¿ªVisual Sutdio 2008 µÄÃüÁîÌáʾÐй¤¾ßÊäÈëguidgen.exe Ñ¡ÔñD ......
Ò»¡¢ºǫ́£¨.csÎļþ£©·½·¨£º
public string GetString(string name)
{
return ("Hello " + name);
}
&n ......
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
<price>5.95</price& ......
¸Õ¿ªÊ¼ºÜ²»Ï°¹ßc#µÄ·ç¸ñ£¬°¥£¬ÏÈÈëΪÖ÷°¡£¬delphiϰ¹ßÁË£¬{}´úÌæbegin/endÌ«ÔúÑÛ¡£
ÊôÐÔ·½·¨µÄÐû¸æºÍ´úÂëÔÚÒ»Æð£¬Ã»ÓÐÏñdelphi·Öinterface/implementation£¬¸Ð¾õÌ«ÂÒ£¬¶¼²»ÖªµÀÒ»¸öclassµ½µ×Óм¸¸ö·½·¨¡£
ÿ¸öÊôÐԺͷ½·¨Ç°Ãæ¶¼Òªµ¥¶Àдprivate/protected/public£¬ÀÏÌ죬c#ÊÇdelphiÖ®¸¸Éè¼ÆµÄÞÞ£¬Ôõô²»Ñ§delphiдһ¸ö¾ÍÐÐ ......
C#µÄToolTip£¨delphi½ÐHint£©»úÖÆ·Ç³£¹Ö£¬²»ÊÇÏñdelphiµÄÔª¼þÒ»Ñù£¬Ã¿¸öTControlÓÐÒ»¸öHintÊôÐÔ£¬C#ÓÐÒ»¸öToolTipÔª¼þ£¬µ±°ÑÕâ¸öÔª¼þ´Ó¹¤¾ßÏäÀµ½formÉϺó£¬Ñ¡ÖÐformÉϵÄÈκÎcontrolÔª¼þ£¬ÔÚÊôÐÔ´°Ì壨Object Inspector£©ÉϾͻá¶à³öÒ»¸öÊôÐÔ“toolTip1ÉϵÄToolTip”£¬Èç¹û¶àÀ¼¸¸ ......