DEV261 2007...

32
DEV261 DEV261 2007 2007 Office Office 客户端开发增强 客户端开发增强

Transcript of DEV261 2007...

Page 1: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

DEV261DEV26120072007 OfficeOffice客户端开发增强客户端开发增强

Page 2: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

课程内容概述课程内容概述

在在Office 2007Office 2007客户端众多新特性中,和使用者关客户端众多新特性中,和使用者关系 为密切的应该是在系 为密切的应该是在UIUI方面的增强。例如,方面的增强。例如,Office 2007Office 2007摒弃了传统以计算机命令作为功能组摒弃了传统以计算机命令作为功能组织单位的菜单,而替换为以用户命令为组织单位织单位的菜单,而替换为以用户命令为组织单位的的RibbonRibbon,这使得用户可以根据当前正在操作的,这使得用户可以根据当前正在操作的文档内容,快速定位到想要执行的操作。对于每文档内容,快速定位到想要执行的操作。对于每一个信息工作者而言,一个信息工作者而言,UIUI增强将很大程度到提高增强将很大程度到提高我们编写文档的质量和效率,而对于每个开发人我们编写文档的质量和效率,而对于每个开发人员而言,对于员而言,对于Office ClientOffice Client用户界面可扩展性的增用户界面可扩展性的增强和包括强和包括Open XMLOpen XML这种开发存储格式的提供使得这种开发存储格式的提供使得对于对于Office ClientOffice Client端的扩展和开发变得随心所欲。端的扩展和开发变得随心所欲。

Page 3: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

课程内容安排课程内容安排

新一代的新一代的20072007 OfficeOffice客户端增强客户端增强

随心所欲操控新的随心所欲操控新的OfficeOffice OpenOpen XMLXML格式文档格式文档

扩展和定制扩展和定制20072007 OfficeOffice客户端,包括客户端,包括VSTOVSTO 3.03.0,,扩展扩展RibbonRibbon,创建自定义任务面板等,创建自定义任务面板等

MicrosoftMicrosoft 20072007 OfficeOffice SystemSystem开发展望开发展望

Page 4: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

微软微软OfficeOffice一路走来一路走来

Page 5: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

现在的用户界面遇到了什么瓶颈现在的用户界面遇到了什么瓶颈??Menus and toolbars were designed for less full-featured programs

The feature set of Office has grown and stretched existing UI mechanisms to the limit

It’s harder to find functionality than it was a decade ago“There must be a way to do this…”“I don’t even know where to start looking.”

050

100150200250300

Word 1

.0Wor

d 2.0

Word 9

5Wor

d 200

0Wor

d 200

3Menu Items

05

101520253035

Word 1

.0Wor

d 2.0

Word 95

Word 2

000

Word 2

003

ToolbarsTask Panes

Page 6: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

直观印象:下一代的直观印象:下一代的20072007 OfficeOffice到底是什么样子到底是什么样子的?的?

Page 7: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

Ribbons Ribbons 和和 GroupsGroups

RibbonReplacement for menus and toolbarsAssociated with a tabs and organized around specific scenarios or objectsModeless UI designed for easy browsing

GroupEach ribbon is organized into several groupsContains related controls:

Richer content than menus/toolbars Buttons, galleries, dialog box content…

Giving users one central place for functionalityGiving users one central place for functionality

Page 8: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

全新用户界面大观

The “Ribbon”GalleriesLive PreviewContextual ToolsQuick Access Toolbar (“QAT”)“Super Tooltips”

“KeyTips” and Keyboard NavigationStreamlined OptionsContext MenusNew File Menu

Page 9: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

新的文件扩展名新的文件扩展名

Macro-Free Macro-Enabled

Document Template Document Template

docxdocx dotxdotx docmdocm dotmdotm

pptxpptx potxpotx pptmpptm potmpotm

xlsxxlsx xltxxltx xlsmxlsm xltmxltm

Open Packaging Convention

Page 10: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

新的新的OfficeOffice文档格式:文档格式:OpenOpen XMLXMLOfficeOffice变成了一个基于变成了一个基于XMLXML的文档格式的文档格式

基于微软基于微软OfficeOffice开发开发XMLXML格式标准格式标准

应用到了应用到了Word, ExcelWord, Excel和和PowerPointPowerPointOfficeOffice保存为一个包含各个组成部分的压缩文件保存为一个包含各个组成部分的压缩文件

文档的组成部分保存为清晰的、开放的文档的组成部分保存为清晰的、开放的XMLOXMLO格式格式

Developers can read specific parts of a Word or Excel file with a simple XML

parser

Developers can read specific parts of a Developers can read specific parts of a Word or Excel file with a simple XML Word or Excel file with a simple XML

parserparser

Developers can read and modify Office documents without requiring Office or

using the Office object models

Developers can read and modify Office Developers can read and modify Office documents without requiring Office or documents without requiring Office or

using the Office object modelsusing the Office object models

Developers can easily replace or remove parts of a document such as

the styles, graphics or comments

Developers can easily replace or Developers can easily replace or remove parts of a document such as remove parts of a document such as

the styles, graphics or commentsthe styles, graphics or comments

Valuable for both client-side and server-side development

Valuable for both clientValuable for both client--side and side and serverserver--side developmentside development

Word Document (ZIP file)Word Document (ZIP file)Word Document (ZIP file)

Document PropertiesDocument Properties

CommentsComments

Document Content as WordMLDocument Content as WordML

CustomCustom--defined XMLdefined XML

Images / Sounds / VideoImages / Sounds / Video

Embedded code / macrosEmbedded code / macros

ChartsCharts

Page 11: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

使用使用““ WinZipWinZip ””来编辑来编辑MicrosoftMicrosoft WordWord文档文档

自己编写程序来创建一个自己编写程序来创建一个MicrosoftMicrosoft WordWord文档文档

Page 12: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

代码分析:代码分析:WinFX Packaging APIWinFX Packaging API

Microsoft WinFX Software Development Kit (SDK)System.IO.Packaging namespace

add document parts, retrieve and update contents, or create new relationships

Important ClassesPackage, PackagePart, PackageRelationship

Page 13: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

System.IO.PackagingSystem.IO.Packaging

Windowsbase.dllWindowsbase.dllWindowsbase.dll

Page 14: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

兼容性兼容性

旧有版本创建的Office文档(如Office 2000, OfficeXP, Office 2003)可以在2007 Office中打开

仅仅安装了就有版本Microsoft Office的用户只需要安装一个扩展包,就可以直接打开、编辑2007Office创建的文档

2007 Office客户端仍然可以把Office文档保存成以前的格式

Page 15: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

OfficeOffice开发,开发,VSTOVSTO才是王道才是王道

Visual Studio Tools for the Microsoft Office System v3 (VSTO 3.0)Highly streamlined developer experienceDocument-level Customizations

Microsoft Excel Microsoft WordMicrosoft InfoPath

Application-level Add-ins

Page 16: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

VSTO RoadmapVSTO Roadmap

VSTO 2003VSTO 2003DocumentDocument--level code behindlevel code behind

Brings Office into the managed worldBrings Office into the managed worldStrict security modelStrict security model

VSTO 2005VSTO 2005Custom ActionsPaneCustom ActionsPane

Host Controls on the document surfaceHost Controls on the document surfaceCached Data in the documentCached Data in the documentServerServer--side data processingside data processingAppApp--level addlevel add--ins for Outlookins for Outlook

ManifestManifest--based deployment & updatebased deployment & update

O12O12--specifics : new features, file format, UIspecifics : new features, file format, UIAppApp--level addlevel add--ins for most client programsins for most client programs

Deeper server side programmingDeeper server side programmingExcel UserExcel User--Defined Funcs (client/server)Defined Funcs (client/server)

Workflow & SharePoint supportWorkflow & SharePoint supportMobile device supportMobile device support

VSTO Version 3.0 VSTO Version 3.0 (early thinking)(early thinking)

Page 17: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

更多的更多的OfficeOffice开发向导开发向导

Page 18: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

Host ControlsHost Controls

BookmarkBookmark

XmlNodeXmlNode

RangeRange

ListList

ChartChart

BookmarkBookmark

XmlNodeXmlNode

NamedRangeNamedRange

ListObjectListObject

ChartObjectChartObject

First class .NET object extending Office object model types

Inherits members of underlying objectEnhanced functionalityNew eventsData binding supportResolution of Event/Method CollisionsTag field & Parameterized Property Fix for C#Core Tasks Task

Panes

Custom Ribbon Extensions

Page 19: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

Windows Forms ControlsWindows Forms Controls

Use normal Windows controls in Word documents and Excel spreadsheetsEmbedded in VSTO-defined ActiveX container

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 20: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

数据绑定数据绑定 DatabindingDatabinding

Builds on ADO.NETBuilds on ADO.NETProgram against data instead of Word and Excel object modelsProgram against data instead of Word and Excel object modelsBind multiple controls to same DataSetBind multiple controls to same DataSetTwo types of bindingTwo types of binding

Simple (Binding a field to the property of a view control)Simple (Binding a field to the property of a view control)Complex (Binding multiple field values to a control)Complex (Binding multiple field values to a control)

Data sources include:Data sources include:Web ServiceWeb ServiceDatabaseDatabaseDataSetDataSetCustom ObjectCustom Object

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 21: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

创建一个创建一个VSTOVSTO WordWord 20072007项目,使用项目,使用HostHost controlcontrol和和WindowsWindows ControlControl来进行数据绑定来进行数据绑定

Page 22: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

定制定制Office 2007 Office 2007 用户界面用户界面ScenariosScenarios

ISV with ERP solution can create ISV with ERP solution can create applicationapplication--wide ribbon wide ribbon extensions that allow users to extensions that allow users to access their information from access their information from within all Office 2007 products within all Office 2007 products that support the new UXthat support the new UX

Add your own tabsAdd your own tabsAdd your own groups to builtAdd your own groups to built--in in tabstabsAdd to the File menuAdd to the File menuAdd to builtAdd to built--in contextual tabsin contextual tabsRepurpose builtRepurpose built--in controlsin controls

Core TasksCore Tasks TaskTaskPanesPanes

Custom Ribbon ExtensionsCustom Ribbon Extensions

Page 23: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

Ribbon ComponentsRibbon ComponentsReviewReview

Ribbon accessible via a tabA Ribbon contains one or more groupsA group contains one or more controls

New controls: ToggleButtons, SplitButtons, EditBoxes, DropDowns, ComboBoxes, CheckBoxes, DropDownGrids

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 24: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

Ribbon XML FileRibbon XML FileArchitectureArchitecture

ribbonribbontabstabs

tabtabgroupgroup

controlcontrolgroupgroup

controlcontrol

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 25: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

DocumentDocument--Level Custom UILevel Custom UIStepsSteps

1.1. Create ribbon XML fileCreate ribbon XML file2.2. Open Office 2007 zip packageOpen Office 2007 zip package3.3. Add ribbon XML file to zip packageAdd ribbon XML file to zip package4.4. Add new content typeAdd new content type

5.5. Add new relationshipAdd new relationship

6.6. Package back again as Office 2007 documentPackage back again as Office 2007 document

<Override PartName="/customui/customui.xml<Override PartName="/customui/customui.xml““ ContentType="application/xml"/>ContentType="application/xml"/>

<Relationship Id="rId<Relationship Id="rId**““ Type=Type="http://schemas.microsoft.com/office/2006/relationships/ui/exten"http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" sibility"

Target="customui/customui.xml"/> Target="customui/customui.xml"/>

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 26: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

Action HandlersAction Handlers

Create procedure (VBA or .NET)

Hook it up with the control in the ribbon XML

Sub Sub YourActionHandlerProcedureYourActionHandlerProcedure(ByVal control As Variant)(ByVal control As Variant)

Your CodeYour Code

End SubEnd Sub

<button id="buttonGenerateRefNumber" label="Reference Number" <button id="buttonGenerateRefNumber" label="Reference Number"

size="large" size="large" onAction=onAction=““YourActionHandlerYourActionHandler""/>/>

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 27: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

给一个文档增加一个自定义给一个文档增加一个自定义RibbonRibbon

Page 28: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

定制定制Office 2007 Office 2007 客户端的界面客户端的界面Your optionsYour options

Document-level (static)Include custom UI in the file packageMake action handlers available in Visual Basic for Applications (VBA)

Application-level (dynamic)Load custom UI via add-inMake action handlers available in add-in

Specific Doc/TemplateSpecific Doc/Template

Doc Doc PartsParts

Custom UICustom UI

ActionActionHandlersHandlers

Any DocumentAny Document

Custom UICustom UI ActionActionHandlersHandlers

AddAdd--InIn

Core Tasks TaskPanes

Custom Ribbon Extensions

Page 29: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

定制任务面板定制任务面板 ((Task PanesTask Panes))ScenariosScenarios

ISV creating a smart documentsolution for helping a sales personcreating a sales proposal

ISV creating a task pane that can be activated by the user in order for him to access the ISVspecific information (e.g. from a back-end financial LOB system)

Core TasksCore Tasks TaskTaskPanesPanes

Custom Ribbon ExtensionsCustom Ribbon Extensions

Page 30: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

创建一个文档级别的任务面板创建一个文档级别的任务面板

Page 31: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily

MicrosoftMicrosoft 20072007 OfficeOffice SystemSystem开发展望开发展望

CollaborationCollaboration Content Content managementmanagement

Streamlined Streamlined processesprocesses

PortalsPortals

Business Business intelligenceintelligence

SearchSearch

Word Word processingprocessing

Business Business modelingmodeling

PresentationsPresentations Business data Business data managementmanagement

InformationInformationManagementManagement

Page 32: DEV261 2007 Office客户端开发增强download.microsoft.com/download/3/7/3/3738f4f6-56eb-4c81... · 2018. 10. 13. · 在Office 2007 客户端众多新 ... Developers can easily