日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

MS Word 編程心得

系統(tǒng) 1881 0
近來公司有個MS Office 編程的活,借機也研究了一下,略有收獲,不敢獨享,希望大家扔雞蛋,但最好不是臭的。
這個項目里,主要是想將Word ,Excel做成的文檔中的圖形導出為XML文件。

這里的關鍵是找出文檔中的圖形對象,并識別出類型。做法如下:
??? ??? ??? ApplicationClass app = new ApplicationClass();
??????????? Document doc = null;
??????????? object missing = System.Reflection.Missing.Value;

??????????? object FileName = @"E:\aa.doc";// Sample Doc
??????????? object readOnly = false;
??????????? object isVisible = true;
??????????? object index = 0;
??????????? try
??????????? {
??????????????? doc = app.Documents.Open(ref FileName, ref missing, ref readOnly,
??????????????????? ref missing, ref missing, ref missing, ref missing, ref missing,
??????????????????? ref missing, ref missing, ref missing, ref isVisible, ref missing,
??????????????????? ref missing, ref missing, ref missing);

??????????????? doc.ActiveWindow.Selection.WholeStory();
??????????????? doc.ActiveWindow.Selection.Copy();
??????????????
??????????????? foreach (Microsoft.Office.Interop.Word.Shape shape in doc.Shapes)
??????????????? {
??????????????????? Console.WriteLine("WordShape-->" + shape.Name);
??????????????? }
??? ??? }finally
??? ??? {
??? ?? ?? ?? ?? if (doc != null)
??????????????? {
??????????????????? doc.Close(ref missing, ref missing, ref missing);
??????????????????? doc = null;
??????????????? }

??????????????? if (app != null)
??????????????? {
??????????????????? app.Quit(ref missing, ref missing, ref missing);
??????????????????? app = null;
??????????????? }
??? ??? }
輸出為:
=================================
WordShape-->Canvas 3
WordShape-->Rectangle 7
WordShape-->Oval 8
WordShape-->Text Box 9
WordShape-->Text Box 12
WordShape-->AutoShape 13
Text-->
Aaa
A

A
A
=================================
aa.doc截圖如下:

MS Word 編程心得

剩下的怎么做不用多說了吧!!!

關于建立,讀取,存儲 Office文檔,我想網(wǎng)上有都是,不細說了。不懂的可參考下面鏈接:
??
http://msdn2.microsoft.com/en-us/library/aa140045(office.10).aspx ? MSDN的很基礎的。

http://www.cnblogs.com/macroxu-1982/archive/2006/11/27/573856.html 一位Blog仁兄的,高手。




MS Word 編程心得


更多文章、技術交流、商務合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 定安县| 淄博市| 蕲春县| 甘孜| 平远县| 常山县| 西充县| 乌兰浩特市| 德化县| 衡阳市| 桑植县| 双峰县| 广汉市| 南投市| 镇江市| 青田县| 高邮市| 铜川市| 保山市| 广水市| 徐水县| 布尔津县| 合水县| 桃园县| 灌阳县| 贡嘎县| 繁昌县| 达孜县| 福清市| 金阳县| 巴中市| 措勤县| 承德县| 旅游| 沛县| 嘉荫县| 磐安县| 临澧县| 东宁县| 宝山区| 锡林浩特市|