關(guān)于我們
書(shū)單推薦
新書(shū)推薦
|
VSTO開(kāi)發(fā)入門(mén)教程
本書(shū)從初學(xué)者角度出發(fā),詳細(xì)介紹了使用C#語(yǔ)言進(jìn)行VSTO開(kāi)發(fā)需要掌握的知識(shí)。全書(shū)分為12章,
內(nèi)容包括VSTO入門(mén)概述、C#語(yǔ)法基礎(chǔ)、C#進(jìn)階技術(shù)、C#操作Excel對(duì)象、創(chuàng)建Office外接程序、自定義
Office功能區(qū)、自定義任務(wù)窗格、自定義工具欄,VSTO外接程序的部署分發(fā)、VSTO開(kāi)發(fā)Office文檔、
VSTO開(kāi)發(fā)資源大全、C#與VB/VBA語(yǔ)言的差異對(duì)比。書(shū)中所有章節(jié)涉及的程序代碼都給出了詳細(xì)的注
釋。本書(shū)可以讓讀者輕松熟悉Visual Studio開(kāi)發(fā)環(huán)境,跨入C#編程的門(mén)檻,掌握VSTO開(kāi)發(fā)的步驟。
本書(shū)可作為職場(chǎng)辦公人員、高校理工科師生、Office專(zhuān)業(yè)開(kāi)發(fā)人員自學(xué)用書(shū),也可以作為Office編
程培訓(xùn)講師的教學(xué)參考書(shū)。
? 資深軟件開(kāi)發(fā)專(zhuān)家撰寫(xiě),系統(tǒng)且深入闡釋VSTO開(kāi)發(fā)涉及的工具、方法和實(shí)踐? 由淺入深剖析VSTO開(kāi)發(fā)過(guò)程中遇到的各個(gè)層面的問(wèn)題,涉及Visual Studio、C#開(kāi)發(fā)、創(chuàng)建Office外接程序、自定義Office功能區(qū)、任務(wù)窗格、自定義工具欄等
VSTO是指Visual Studio Tools for Offi ce,其含義是在Visual Studio開(kāi)發(fā)環(huán)境中進(jìn)行Offi ce專(zhuān)業(yè)開(kāi)發(fā)。Visual Studio是目前最流行的Windows平臺(tái)應(yīng)用程序的集成開(kāi)發(fā)環(huán)境。VSTO是VBA的替代,使得開(kāi)發(fā)Office應(yīng)用程序更加簡(jiǎn)單,并且用VSTO來(lái)開(kāi)發(fā)Office應(yīng)用程序可以使用Visual Studio開(kāi)發(fā)環(huán)境中的眾多功能。VSTO是一套用于創(chuàng)建自定義Office應(yīng)用程序的Visual Studio工具包,可以用Visual Basic或者Visual C#擴(kuò)展Office應(yīng)用程序(例如Word、Excel、PowerPoint和Outlook)。正是由于VSTO具有諸多優(yōu)勢(shì),吸引了越來(lái)越多的人開(kāi)始轉(zhuǎn)入研究VSTO開(kāi)發(fā),但是到目前為止,國(guó)內(nèi)還沒(méi)有一本比較適合初學(xué)者的入門(mén)教材,網(wǎng)絡(luò)上查到的相關(guān)知識(shí)點(diǎn)也比較片面。本書(shū)是國(guó)內(nèi)第一部關(guān)于VSTO開(kāi)發(fā)Office的經(jīng)典書(shū)籍,作者根據(jù)自己的開(kāi)發(fā)經(jīng)驗(yàn),將開(kāi)發(fā)過(guò)程中的關(guān)鍵技術(shù)和要點(diǎn)都融入本書(shū)。全書(shū)共12章,作者從讀者的角度考慮,編排了從Visual Studio的安裝、C#語(yǔ)言入門(mén),一直到創(chuàng)建第一個(gè)完整的VSTO項(xiàng)目,基本是手把手地告訴讀者每一個(gè)環(huán)節(jié)。讀者閱讀本書(shū)后,可以自行開(kāi)發(fā)完整的VSTO項(xiàng)目,并制作成可以分發(fā)的安裝包。最重要的是,通過(guò)本入門(mén)教程的學(xué)習(xí),能讓讀者增強(qiáng)信心,產(chǎn)生進(jìn)一步深入研究和探索VSTO的興趣。也許很多讀者朋友看到諸如Visual Studio、C#這樣的字眼望而生畏,其實(shí)VSTO并沒(méi)有想象的那么難,只要按照本教程按部就班學(xué)習(xí),結(jié)合視頻教程的講解,很快就能掌握這項(xiàng)開(kāi)發(fā)技術(shù)。VSTO學(xué)習(xí)路線圖對(duì)于VSTO的初學(xué)者,可以按照如下的路線圖進(jìn)行系統(tǒng)學(xué)習(xí)。如果是已經(jīng)具有Visual Studio和C#基礎(chǔ)的讀者,則可以直接從第三階段學(xué)起。
VSTO 開(kāi)發(fā)入門(mén)教程第一階段:熟悉Visual Studio編程環(huán)境? 理解VSTO的概念? 安裝Visual Studio? 熟悉解決方案和項(xiàng)目文件夾第二階段:熟悉C#語(yǔ)言? 創(chuàng)建C#窗體應(yīng)用程序、窗體與常用控件的使用? C#語(yǔ)法基礎(chǔ)(變量、控制語(yǔ)句、不同數(shù)據(jù)類(lèi)型的轉(zhuǎn)換等)? 程序代碼調(diào)試、錯(cuò)誤處理? 使用類(lèi)第三階段:C#操作和控制Excel對(duì)象? 熟悉Excel對(duì)象模型,Excel對(duì)象的常用屬性、方法和事件? 加強(qiáng)從VBA代碼向C#代碼遷移的能力第四階段:界面設(shè)計(jì)部分? 定制功能區(qū):使用功能區(qū)設(shè)計(jì)器或使用XML代碼,理解Custom UI機(jī)制? 任務(wù)窗格:任務(wù)窗格中控件和用戶(hù)控件的添加? 創(chuàng)建文檔自定義項(xiàng),使用文檔操作窗格? 自定義工具欄第五階段:VSTO項(xiàng)目分發(fā)與安裝程序的制作? 使用Advanced Installer其他知識(shí)點(diǎn)? 使用C#制作Excel自定義函數(shù)(UDF)? 創(chuàng)建Word、PPT等組件的VSTO項(xiàng)目VSTO課程學(xué)習(xí)路線圖本書(shū)內(nèi)容本書(shū)內(nèi)容以VSTO學(xué)習(xí)路線圖為依據(jù)編排而成,全書(shū)共分12章。第1章:VSTO入門(mén)概述本書(shū)介紹的是一項(xiàng)程序開(kāi)發(fā)技術(shù),因此首先要讓讀者安裝必要的程序語(yǔ)言和開(kāi)發(fā)環(huán)境。然后講述VSTO開(kāi)發(fā)的意義和任務(wù),以及創(chuàng)建和調(diào)試C#解決方案的方法與步驟。第2章:C#語(yǔ)法基礎(chǔ) III本書(shū)以C#為開(kāi)發(fā)語(yǔ)言,因此讀者需要掌握一定程度的C#語(yǔ)法基礎(chǔ)。該章介紹了變量的聲明和賦值、流程控制與類(lèi)的使用。第3章:C#進(jìn)階技術(shù)該章講述了C#窗體與控件的相關(guān)技術(shù),以及像正則表達(dá)式、字典等高級(jí)對(duì)象的用法,目的是讓讀者在開(kāi)發(fā)過(guò)程中,能夠熟練應(yīng)用這些高級(jí)對(duì)象去處理實(shí)際問(wèn)題。第4章:C#操作Excel對(duì)象前面3章講述的是純粹的C#語(yǔ)言,而從這一章開(kāi)始,講述如何使用C#操作和控制Office對(duì)象,該章以Excel為例,介紹了Excel的應(yīng)用程序、工作簿、工作表、單元格區(qū)域等對(duì)象的成員。第5章:創(chuàng)建Office外接程序VSTO開(kāi)發(fā)的目的旨在創(chuàng)建Office外接程序(即COM加載項(xiàng))。該章介紹了COM加載項(xiàng)的工作原理和開(kāi)發(fā)基本步驟。第6章:自定義Office功能區(qū),第7章:自定義任務(wù)窗格第6章和第7章分別介紹了VSTO開(kāi)發(fā)的重點(diǎn),一般來(lái)說(shuō),創(chuàng)建一個(gè)Office外接程序,界面定制是非常必要的,為此本書(shū)在這兩章里詳盡地介紹了功能區(qū)的自定義技術(shù)和自定義窗格的設(shè)計(jì)方法。第8章:自定義工具欄Office工具欄是Office組件中很重要的一個(gè)界面對(duì)象,為此本書(shū)通過(guò)典型的實(shí)例,講述了工具欄和控件的自定義方法。第9章:VSTO外接程序的部署分發(fā)VSTO開(kāi)發(fā)的成品,一般需要能夠在其他計(jì)算機(jī)上正常使用,為此,該章介紹了使用Advanced Installer軟件來(lái)創(chuàng)建VSTO項(xiàng)目的安裝程序。第10章:VSTO開(kāi)發(fā)Office文檔文檔自定義開(kāi)發(fā)是VSTO另一類(lèi)型的項(xiàng)目。該項(xiàng)目允許自定義文檔,可以向文檔中加入C#控件,以及創(chuàng)建和控制文檔窗格。第11章:VSTO開(kāi)發(fā)資源大全工欲善其事,必先利其器,為了能夠駕輕就熟地進(jìn)行VSTO開(kāi)發(fā),還需要使用其他一些工具的輔助,為此,該章介紹了典型工具的安裝和使用技巧。第12章:C#與VB/VBA語(yǔ)言的差異對(duì)比考慮到很多讀者是從VBA轉(zhuǎn)過(guò)來(lái)的,對(duì)VBA的語(yǔ)法和對(duì)象模型更為熟悉,為了能夠幫助讀者更快地從VBA轉(zhuǎn)入VSTO,該章列出了兩種語(yǔ)言典型的語(yǔ)法差異。 VSTO 開(kāi)發(fā)入門(mén)教程本書(shū)特點(diǎn)本書(shū)是目前市面上稀缺而Office開(kāi)發(fā)人員急需的、Office和C#技巧完美融合的經(jīng)典書(shū)籍,為了讓讀者快速了解和熟悉VSTO,本書(shū)第2~4章的C#代碼都配備了對(duì)應(yīng)的VBA代碼,可以讓之前從事VBA開(kāi)發(fā)的讀者迅速學(xué)會(huì)VSTO開(kāi)發(fā)。同時(shí)本書(shū)配套資源中包括本書(shū)涉及的所有項(xiàng)目的源文件,以便讀者加以驗(yàn)證和核對(duì)。另外,本書(shū)配套資源中還有與VSTO開(kāi)發(fā)相關(guān)的全部有聲視頻教程。本書(shū)配套資源內(nèi)容說(shuō)明本書(shū)配套資源包括VSTO開(kāi)發(fā)入門(mén)視頻教程、本書(shū)所有示例程序、VSTO開(kāi)發(fā)資源大全三大部分內(nèi)容。關(guān)于本書(shū)配套資源,讀者可訪問(wèn)http://vba.mahoupao.net/forum.php?mod=viewthread&tid=2407&fromuid=1進(jìn)行下載。大分類(lèi)文件名對(duì)應(yīng)章節(jié)或描述VSTO開(kāi)發(fā)入門(mén)視頻教程VSTO概述.wmv 第1章C#語(yǔ)法基礎(chǔ).wmv 第2章類(lèi)的創(chuàng)建和使用.wmv 2.12節(jié)窗體和控件的設(shè)計(jì)技術(shù).wmv 3.7節(jié)C#操作Excel對(duì)象.wmv 第4章創(chuàng)建Office外接程序.wmv 第5章使用Ribbon設(shè)計(jì)器自定義Office功能區(qū).wmv 6.4節(jié)使用XML自定義Office功能區(qū).wmv 6.5節(jié)自定義任務(wù)窗格的設(shè)計(jì).wmv 第7章VSTO外接程序的打包.wmv 第9章VSTO開(kāi)發(fā)Office文檔-文檔操作窗格.wmv 第10章示例程序ConsoleApplication20160629 1.2.1節(jié)ExcelAddIn20160514 6.4節(jié)ExcelAddIn20160515 6.5節(jié)ExcelAddIn20160516 7.2節(jié)ExcelAddIn20160517 8.2.1節(jié)ExcelWorkbook20160519 10.3節(jié)Solution20160705 1.4節(jié)UDF20160521 4.9.1節(jié)VSTOBOOK-C# 第2章VSTOBOOK-VB 第2章WindowsFormsApplication20160522 4.2節(jié)WindowsFormsApplication20160523 3.4節(jié) 大分類(lèi)文件名對(duì)應(yīng)章節(jié)或描述示例程序WindowsFormsApplication20160524 3.5.4節(jié)WindowsFormsApplication20160525 3.6節(jié)WindowsFormsApplication20160526 3.7節(jié)WindowsFormsApplication20160527 3.7.9節(jié)WindowsFormsApplication20160528 3.8節(jié)WindowsFormsApplication20160606 2.2節(jié)WindowsFormsApplication20160625 2.12節(jié)WindowsFormsApplication20160629 1.2.2節(jié)VSTO開(kāi)發(fā)資源大全OfficeCommandbarDesigner20160709.rar11.1節(jié)OfficeCommandbarViewer20160709.rarFaceIDs_V2_20160709.xlsFaceIDs_V2_20160709.docOffice2010ControlIDs.rar11.2節(jié)imageMso7345.xlsmOfficeCustomUIEditorSetup.msiRibbonXMLEditor20160709.rarribbon回調(diào)函數(shù)大全.xlsmUseAPI.rar 3.8節(jié)VBE2014_Setup_2016070911.3節(jié)VisualStudioAddin2016Setup.exe讀者對(duì)象● 職場(chǎng)辦公人員● 理工科類(lèi)大學(xué)生、研究生● 編程愛(ài)好者● 培訓(xùn)機(jī)構(gòu)的老師和學(xué)員本書(shū)約定書(shū)中述及的多級(jí)菜單和工具欄的圖示中,鼠標(biāo)單擊的各級(jí)菜單或命令均放在中文方括號(hào)之中,各級(jí)之間以斜杠隔開(kāi)。例如【文件/打開(kāi)】表示連續(xù)單擊了文件菜單的打續(xù)表VSTO 開(kāi)發(fā)入門(mén)教程開(kāi)子菜單。書(shū)中所有的VBA和C#代碼段,代碼左側(cè)均有行號(hào),這些行號(hào)只是為了便于講解,并不屬于代碼部分。讀者服務(wù)為了方便本書(shū)內(nèi)容答疑,讀者朋友可加入VBA/VSTO開(kāi)發(fā)QQ群:61840693,也可以在VBA/VSTO論壇(http://vba.mahoupao.net/forum.php)發(fā)帖,還可以直接給作者發(fā)Email:lyflyf715@sina.com。無(wú)論哪一種方式,作者將竭誠(chéng)為您服務(wù)。如果要進(jìn)一步學(xué)習(xí)Office、VBA、VSTO等學(xué)科的視頻課程,讀者可在51CTO學(xué)院搜索作者主講的相關(guān)課程:http://edu.51cto.com/user/user_id-6673733.html。致謝感謝劉愛(ài)珍、儒道佛潘淳、西西老師、張杰、聞啟學(xué)等朋友以及兄長(zhǎng)劉永和在本書(shū)編寫(xiě)過(guò)程中給予的無(wú)私幫助和鼓勵(lì)。本書(shū)在出版過(guò)程中,得到了清華大學(xué)出版社策劃編輯秦健先生的大力支持和配合,在此表示衷心感謝。另外,本書(shū)所有的編審、發(fā)行人員為本書(shū)的出版和發(fā)行付出了辛勤勞動(dòng),在此一并致謝。特別說(shuō)明本書(shū)編寫(xiě)時(shí)所用的VSTO開(kāi)發(fā)環(huán)境如下:● 操作系統(tǒng):Windows 7(32bit)● Office:Office 2010完整版● Visual Studio:Visual Studio 2012● 開(kāi)發(fā)語(yǔ)言:C#讀者可以根據(jù)自身?xiàng)l件適當(dāng)調(diào)整。另外,本書(shū)涉及的所有VSTO示例,均以Excel 2010為開(kāi)發(fā)對(duì)象,對(duì)于其他Office組件的開(kāi)發(fā),過(guò)程非常類(lèi)似,讀者可以在Excel開(kāi)發(fā)的基礎(chǔ)上自行探索。致讀者微軟Office套件稱(chēng)得上是全世界最成功的辦公軟件,擁有非常多的用戶(hù)。它之所以受到人們的青睞,有多方面的原因,但是以下幾點(diǎn)是有目共睹的:一是功能完善而且強(qiáng)大;二是容易操作,用戶(hù)容易學(xué)會(huì);三是具有強(qiáng)大的編程開(kāi)發(fā)功能。 VII隨著計(jì)算機(jī)的發(fā)展,以往的手工操作辦公軟件已經(jīng)不能滿足現(xiàn)代辦公的需要,因此,VBA以及VSTO開(kāi)發(fā)和應(yīng)用技術(shù)應(yīng)運(yùn)而生。本書(shū)在編寫(xiě)過(guò)程中,受到了眾多Office開(kāi)發(fā)人員的關(guān)注,他們殷切希望本書(shū)盡早出版。除了劉永富之外,參與本書(shū)編寫(xiě)的人員還有章曉琳、馬成林、鐘卓成、李四桂、何明、段留柱、高大偉、肖云、譚信章、戴海東、朱輝、徐鵬、祝磊、管洪洋、劉愛(ài)珍、王繼成、汪龍、林興龍、梁加成等。在編寫(xiě)過(guò)程中難免會(huì)有漏洞,歡迎讀者通過(guò)清華大學(xué)出版社網(wǎng)站(www.tup.com.cn)與我們聯(lián)系,幫助我們改正提高。劉永富2016年7月于北京 第1章 VSTO入門(mén)概述 ················1 1.1 VSTO簡(jiǎn)述 ·································· 1 1.1.1 VSTO的功能與特點(diǎn) ······················· 1 1.1.2 VSTO開(kāi)發(fā)語(yǔ)言 ····························· 2 1.1.3 VSTO開(kāi)發(fā)環(huán)境配置 ······················· 3 1.1.4 Visual Studio開(kāi)發(fā)環(huán)境 ····················· 4 1.1.5 Visual Studio版本沿革 ····················· 4 1.1.6 Visual Studio的安裝 ························ 4 1.2 創(chuàng)建第一個(gè)C#應(yīng)用程序 ················· 5 1.2.1 控制臺(tái)應(yīng)用程序 ···························· 5 1.2.2 Windows窗體應(yīng)用程序 ··················· 9 1.2.3 生成可執(zhí)行文件 ···························11 1.3 認(rèn)識(shí)Visual Studio開(kāi)發(fā)環(huán)境·············11 1.3.1 【文件】菜單 ······························12 1.3.2 【視圖】菜單 ······························12 1.3.3 【項(xiàng)目】菜單 ······························12 1.3.4 菜單欄和工具欄的自定義 ···············13 1.3.5 Visual Studio選項(xiàng) ··························14 1.4 Visual Studio項(xiàng)目組織結(jié)構(gòu) ·············14 1.4.1 解決方案 ····································14 1.4.2 項(xiàng)目 ··········································17 1.4.3 類(lèi)模塊 ·······································18 1.4.4 引用管理 ····································18 1.5 使用幫助系統(tǒng) ·····························19 1.5.1 設(shè)置幫助查看方式 ························19 1.5.2 下載和安裝Help Viewer ··················19 1.5.3 管理幫助內(nèi)容 ······························19 本章要點(diǎn)回顧····································21 第2章 C#語(yǔ)法基礎(chǔ) ··················· 22 2.1 變量的聲明和賦值 ······················22 2.1.1 常用的數(shù)據(jù)類(lèi)型 ···························22 2.1.2 賦值運(yùn)算符 ·································23 2.1.3 變量的作用范圍 ···························23 2.2 字符與字符串處理 ·······················24 2.2.1 字符變量 ····································24 2.2.2 字符串變量 ·································25 2.2.3 轉(zhuǎn)義字符 ····································26 2.2.4 字符串連接 ·································27 2.2.5 子字符串 ····································27 2.2.6 格式化字符串 ······························28 2.2.7 字符串的替換 ······························28 2.2.8 字符串與數(shù)組 ······························28 2.3 邏輯運(yùn)算 ···································29 2.3.1 布爾型變量 ·································29 2.3.2 比較運(yùn)算符 ·································30 2.3.3 多條件的與或非運(yùn)算 ·····················30 2.4 不同類(lèi)型的強(qiáng)制轉(zhuǎn)換 ····················31 2.4.1 ToString ·····································31 2.4.2 Parse ·········································31 2.4.3 Convert ······································32 2.5 使用數(shù)組 ···································33 2.5.1 數(shù)組的聲明和初始化 ·····················33 2.5.2 一維數(shù)組 ····································33 2.5.3 數(shù)組元素的遍歷 ···························34 2.5.4 二維數(shù)組 ····································35 2.6 條件選擇語(yǔ)句 ·····························37 2.6.1 三元運(yùn)算符 ·································37 2.6.2 if語(yǔ)句 ········································38 2.6.3 switch語(yǔ)句 ··································39 2.7 循環(huán)語(yǔ)句 ···································40 2.7.1 while循環(huán) ···································40 2.7.2 do循環(huán) ·······································41 2.7.3 for循環(huán) ······································42 2.7.4 foreach循環(huán)·································43 2.8 流程控制語(yǔ)句 ·····························43 2.8.1 break語(yǔ)句 ···································43 2.8.2 continue語(yǔ)句 ·······························44 2.8.3 goto語(yǔ)句 ····································44 2.8.4 return語(yǔ)句 ···································45 2.9 輸出對(duì)話框(MessageBox) ··········46 2.9.1 MessageBox語(yǔ)法 ··························46 2.9.2 自定義對(duì)話框的按鈕 ·····················47 2.9.3 自定義對(duì)話框的圖標(biāo) ·····················48 2.9.4 自定義對(duì)話框默認(rèn)按鈕 ··················48 2.9.5 處理對(duì)話框的用戶(hù)響應(yīng) ··················48 2.10 輸入對(duì)話框(InputBox) ·············49 2.11 過(guò)程與函數(shù) ······························50 2.11.1 過(guò)程與函數(shù)的定義 ······················50 2.11.2 過(guò)程與函數(shù)的調(diào)用 ······················51 2.12 類(lèi)的創(chuàng)建和使用 ························52 2.12.1 非靜態(tài)類(lèi) ··································52 2.12.2 靜態(tài)類(lèi) ·····································54 2.13 using指令 ·································55 2.14 錯(cuò)誤處理 ·································55 本章要點(diǎn)回顧····································56 第3章 C#進(jìn)階技術(shù) ···················57 3.1 文件與文件夾操作 ·······················57 3.1.1 System.IO命名空間 ·······················57 3.1.2 文件與文件夾處理實(shí)例 ··················58 3.2 文本文件的讀寫(xiě) ··························59 3.3 數(shù)據(jù)庫(kù)操作 ································60 3.4 使用資源文件 ·····························61 3.4.1 添加資源文件 ······························62 3.4.2 資源文件中的字符串 ·····················62 3.4.3 資源文件中的圖像 ························63 3.5 使用正則表達(dá)式 ··························65 3.5.1 創(chuàng)建Regex對(duì)象 ····························65 3.5.2 元字符 ·······································65 3.5.3 正則表達(dá)式選項(xiàng) ···························66 3.5.4 正則表達(dá)式方法 ···························67 3.5.5 正則表達(dá)式測(cè)試器 ························71 3.6 使用字典 ···································72 3.6.1 字典對(duì)象的創(chuàng)建 ···························72 3.6.2 根據(jù)鍵檢索值 ······························73 3.6.3 遍歷所有鍵名 ······························74 3.6.4 遍歷所有值 ·································74 3.6.5 去除重復(fù) ····································74 3.7 窗體設(shè)計(jì)技術(shù) ·····························76 3.7.1 窗體的顯示 ·································76 3.7.2 窗體的卸載 ·································77 3.7.3 窗體與控件的事件 ························78 3.7.4 使用窗體菜單 ······························82 3.7.5 使用工具欄 ·································85 3.7.6 使用右鍵菜單 ······························87 3.7.7 使用狀態(tài)欄 ·································88 3.7.8 使用文件選擇對(duì)話框 ·····················90 3.7.9 運(yùn)行期間動(dòng)態(tài)增刪控件 ··················91 3.8 使用Windows API 函數(shù) ··················94 3.8.1 窗口類(lèi)名和句柄 ···························95 3.8.2 使用Spy ··································98 3.8.3 使用UseAPI ······························ 100 3.8.4 獲取光標(biāo)位置 ···························· 101 本章要點(diǎn)回顧·································· 101 第4章 C#操作Excel對(duì)象·········· 102 4.1 Excel對(duì)象模型概述 ···················· 102 4.1.1 Application對(duì)象 ·························· 103 4.1.2 Workbook 對(duì)象 ··························· 104 4.1.3 Worksheet 對(duì)象 ··························· 104 4.1.4 Range對(duì)象 ································ 105 4.1.5 Window 對(duì)象 ······························ 105 4.2 創(chuàng)建可以訪問(wèn)Excel對(duì)象的C#窗體 應(yīng)用程序 ································· 105 4.2.1 添加Excel 2010對(duì)象引用 ·············· 105 4.2.2 添加Office 2010對(duì)象引用 ·············· 105 4.3 操作Application對(duì)象 ··················· 107 4.3.1 獲取正在運(yùn)行的Excel對(duì)象 ············ 107 4.3.2 創(chuàng)建新的Excel對(duì)象 ····················· 109 4.3.3 Application對(duì)象常用屬性 ·············· 109 4.3.4 Application對(duì)象常用方法 ·············· 110 4.3.5 Application對(duì)象常用事件 ·············· 110 4.3.6 Application重要集合對(duì)象 ·············· 111 4.4 操作Workbook 對(duì)象···················· 112 4.4.1 Workbook 對(duì)象常用屬性··············· 112 4.4.2 Workbook 對(duì)象常用方法··············· 113 4.4.3 Workbook 對(duì)象常用事件··············· 114 4.4.4 Workbook 重要集合對(duì)象··············· 114 4.5 操作Worksheet 對(duì)象 ···················· 115 4.5.1 Worksheet 對(duì)象常用屬性 ··············· 115 4.5.2 Worksheet 對(duì)象常用方法 ··············· 116 4.5.3 Worksheet 對(duì)象常用事件 ··············· 117 4.6 操作Range對(duì)象 ························· 117 4.6.1 Range對(duì)象常用屬性···················· 117 4.6.2 Range對(duì)象常用方法···················· 118 4.6.3 Range對(duì)象的遍歷 ······················· 119 4.6.4 二維數(shù)組與Range數(shù)據(jù)交換··········· 120 4.6.5 一維數(shù)組與Range數(shù)據(jù)交換··········· 121 4.7 操作Commandbar對(duì)象 ················ 121 4.8 操作VBE工程 ·························· 123 4.8.1 引用VBIDE類(lèi)型庫(kù) ······················ 123 4.8.2 允許對(duì)VBA工程訪問(wèn) ·················· 123 4.8.3 操作VBE各級(jí)對(duì)象 ······················ 125 4.9 創(chuàng)建Excel自定義函數(shù) ················· 125 4.9.1 使用C#創(chuàng)建類(lèi)庫(kù) ························ 126 4.9.2 工作表中使用C#開(kāi)發(fā)的自定義 公式 ········································ 129 4.9.3 VBA中調(diào)用C#開(kāi)發(fā)的自定義公式 ··· 131 4.9.4 C#中調(diào)用C#開(kāi)發(fā)的自定義公式 ······ 131 4.9.5 客戶(hù)機(jī)使用C#制作的自定義函數(shù) ·······132 本章要點(diǎn)回顧·································· 133 第5章創(chuàng)建Office外接程序······· 134 5.1 Office COM加載項(xiàng)簡(jiǎn)介 ··············· 134 5.2 認(rèn)識(shí)Office COM加載項(xiàng)管理 對(duì)話框 ···································· 134 5.3 創(chuàng)建第一個(gè)Office外接程序項(xiàng)目 ····135 5.4 ThisAddin的啟動(dòng)事件和卸載事件 ··136 本章要點(diǎn)回顧··································137 第6章 自定義Office功能區(qū) ·······138 6.1 CustomUI概述 ··························138 6.1.1 CustomUI的意義 ························140 6.1.2 CustomUI的作用范圍 ··················140 6.1.3 手工定制Office界面 ····················140 6.2 CustomUI與XML ·······················141 6.2.1 XML語(yǔ)法規(guī)則 ···························141 6.2.2 描述Office界面的XML ·················142 6.2.3 使用Ribbon XML Editor ···············148 6.3 CustomUI元素詳解 ····················149 6.3.1 選項(xiàng)卡(tab)元素 ·····················150 6.3.2 組(group)元素 ························151 6.3.3 控件(control)元素 ···················151 6.4 VSTO中使用功能區(qū)可視化 設(shè)計(jì)器 ····································154 6.4.1 為按鈕指定回調(diào)過(guò)程 ···················156 6.4.2 Group中加入DialogBoxLauncher ·····157 6.5 使用XML進(jìn)行CustomUI定制 ········159 本章要點(diǎn)回顧··································162 第7章 自定義任務(wù)窗格 ············163 7.1 任務(wù)窗格行為控制 ·····················163 7.2 VSTO外接程序項(xiàng)目中添加任務(wù) 窗格 ·······································164 7.2.1 創(chuàng)建Excel 2010外接程序 ··············165 7.2.2 添加用戶(hù)控件 ····························165 7.2.3 靜態(tài)類(lèi)中聲明任務(wù)窗格對(duì)象 ··········166 7.2.4 創(chuàng)建并顯示任務(wù)窗格 ···················167 7.3 功能區(qū)與任務(wù)窗格的交互控制 ······169 7.3.1 利用功能區(qū)切換按鈕控制任務(wù)窗格的 顯示隱藏 ··································169 7.3.2 處理自定義任務(wù)窗格事件 ·············172 7.3.3 完全卸載任務(wù)窗格 ······················173 本章要點(diǎn)回顧··································173 第8章 自定義工具欄 ···············174 8.1 Office工具欄對(duì)象簡(jiǎn)述 ················174 8.1.1 Commandbar對(duì)象 ·······················174 8.1.2 CommandbarControl對(duì)象 ··············175 8.1.3 自定義工具欄的作用和意義 ··········176 8.2 VSTO實(shí)現(xiàn)自定義工具欄 ·············176 8.2.1 創(chuàng)建自定義工具欄 ······················176 8.2.2 處理工具欄按鈕的回調(diào) ················178 8.2.3 修改右鍵菜單 ····························179 8.2.4 卸載外接程序時(shí)清除自定義 ··········180 本章要點(diǎn)回顧··································181 第9章 VSTO外接程序的部署分發(fā) ···182 9.1 客戶(hù)機(jī)搭建VSTO運(yùn)行環(huán)境 ··········182 9.2 VSTO外接程序的簡(jiǎn)單安裝 ··········183 9.3 使用Advanced Installer ················184 9.3.1 創(chuàng)建aip安裝包工程 ·····················184 9.3.2 客戶(hù)機(jī)運(yùn)行安裝包 ······················193 本章要點(diǎn)回顧··································194 第10章 VSTO開(kāi)發(fā)Office文檔 ···195 10.1 文檔自定義項(xiàng)編程概述 ·············195 10.2 文檔自定義項(xiàng)允許添加的界面 元素 ·····································195 10.3 創(chuàng)建Office文檔項(xiàng)目 ··················196 10.3.1 文檔上添加C#控件 ····················198 10.3.2 文檔項(xiàng)目的啟動(dòng)事件過(guò)程 ···········198 10.4 文檔操作窗格概述 ···················199 10.5 文檔操作窗格綜合實(shí)例 ·············200 10.5.1 添加用戶(hù)控件到文檔窗格 ···········202 10.5.2 添加多個(gè)相同控件到文檔窗格 ·····204 10.5.3 使用代碼創(chuàng)建窗體控件并添加到 文檔操作窗格 ··························205 10.5.4 定制功能區(qū)按鈕控制文檔操作 窗格 ······································206 10.6 文檔自定義項(xiàng)的部署分發(fā) ··········210 本章要點(diǎn)回顧··································211 第11章 VSTO開(kāi)發(fā)資源大全 ·····212 11.1 Office 2003以下版本工具欄和控件的 自定義 ··································212 11.1.1 OfficeCommandbarDesigner ··········212 11.1.2 OfficeCommandbarViewer ············213 11.1.3 FaceIDViewer ···························213 11.2 Office 2007以上版本功能區(qū)的 自定義 ··································215 11.2.1 Office2010ControlIDs ·················215 11.2.2 imageMso7345 ··························216 11.2.3 OfficeCustomUIEditor ·················217 11.2.4 Ribbon XML Editor ····················217 11.2.5 Ribbon回調(diào)函數(shù)大全 ··················217 11.3 編程環(huán)境輔助工具 ···················218 11.3.1 VBE2014 ································219 11.3.2 VisualStudioAddin2016 ···············220 第12章 C#與VB/VBA語(yǔ)言的差異 對(duì)比··························222 12.1 變量必須聲明 ·························222 12.2 嚴(yán)格的類(lèi)型匹配 ······················222 12.3 項(xiàng)目的自動(dòng)保存 ······················222 12.4 嚴(yán)格區(qū)分大小寫(xiě) ······················223 12.5 語(yǔ)句結(jié)束必須加分號(hào) ················223 12.6 語(yǔ)句塊 ··································223 12.7 調(diào)用其他函數(shù)圓括號(hào)不能少 ·······224 12.8 數(shù)組的下標(biāo)為0 ························224 12.9 數(shù)組或集合對(duì)象的索引使用 方括號(hào) ··································225
你還可能感興趣
我要評(píng)論
|