DEV261 2007 Office 客户端开发增强
32 Slides4.31 MB
DEV261 2007 Office 客户端开发增强
课程内容概述 在 Office 2007 客户端众多新特性中,和使用者 关系最为密切的应该是在 UI 方面的增强。例 如, Office 2007 摒弃了传统以计算机命令作为 功能组织单位的菜单,而替换为以用户命令为组 织单位的 Ribbon ,这使得用户可以根据当前正 在操作的文档内容,快速定位到想要执行的操作 。对于每一个信息工作者而言, UI 增强将很大程 度到提高我们编写文档的质量和效率,而对于每 个开发人员而言,对于 Office Client 用户界面可 扩展性的增强和包括 Open XML 这种开发存储格 式的提供使得对于 Office Client 端的扩展和开发 变得随心所欲。
课程内容安排 新一代的 2007 Office 客户端增强 随心所欲操控新的 Office Open XML 格式文档 扩展和定制 2007 Office 客户端,包括 VSTO 3.0 ,扩展 Ribbon ,创建自定义任务面板等 Microsoft 2007 Office System 开发展望
微软 Office 一路走来
现在的用户界面遇到了什么瓶颈 ? Menus and toolbars were designed for less fullfeatured programs 300 250 200 150 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.” Menu Items 100 50 0 35 30 25 20 15 10 5 0 d or W Toolbars Task Panes 0 1. W d or 0 2. W d or 95 W d or 00 20 W d or 03 20
直观印象:下一代的 2007 Office 到底是什么样子 的?
Ribbons 和 Groups Giving users one central place for functionality Ribbon Replacement for menus and toolbars Associated with a tabs and organized around specific scenarios or objects Modeless UI designed for easy browsing Group Each ribbon is organized into several groups Contains related controls: Richer content than menus/toolbars Buttons, galleries, dialog box content
全新用户界面大观 The “Ribbon” Galleries Live Preview Contextual Tools Quick Access Toolbar (“QAT”) “Super Tooltips” “KeyTips” and Keyboard Navigation Streamlined Options Context Menus New File Menu
新的文件扩展名 Macro-Free Document Template Macro-Enabled Document Template docx dotx docm dotm pptx potx pptm potm xlsx xltx xlsm xltm Open Packaging Convention
新的 Office 文档格式: Open XML Office 变成了一个基于 XML 的文档格式 基于微软 Office 开发 XML 格式标准 应用到了 Word, Excel 和 PowerPoint Office 保存为一个包含各个组成部分的压缩文件 文档的组成部分保存为清晰的、开放的 XMLO 格式 Document Properties Comments Document Content as WordML Custom-defined XML Images / Sounds / Video Embedded code / macros Charts Word Word Document Document (ZIP (ZIP file) file) Developers Developers can can read read and and modify modify Office Office documents documents without without requiring requiring Office Office or or using using the the Office Office object object models models Developers Developers can can read read specific specific parts parts of of aa Word or Excel file with a simple XML Word or Excel file with a simple XML parser parser Developers Developers can can easily easily replace replace or or remove remove parts parts of of aa document document such such as as the the styles, styles, graphics graphics or or comments comments Valuable Valuable for for both both client-side client-side and and server-side server-side development development
使用“ WinZip ” 来编辑 Microsoft Word 文档 自己编写程序来创建一个 Microsoft Word 文档
代码分析: WinFX Packaging API Microsoft WinFX Software Development Kit (SDK) System.IO.Packaging namespace add document parts, retrieve and update contents, or create new relationships Important Classes Package, PackagePart, PackageRelationship
System.IO.Packaging Windowsbase.dll
兼容性 旧有版本创建的 Office 文档(如 Office 2000, Office XP, Office 2003 )可以在 2007 Office 中打开 仅仅安装了就有版本 Microsoft Office 的用户只需 要安装一个扩展包,就可以直接打开、编辑 2007 Office 创建的文档 2007 Office 客户端仍然可以把 Office 文档保存 成以前的格式
Office 开发, VSTO 才是王道 Visual Studio Tools for the Microsoft Office System v3 (VSTO 3.0) Highly streamlined developer experience Document-level Customizations Microsoft Excel Microsoft Word Microsoft InfoPath Application-level Add-ins
VSTO Roadmap VSTO Version 3.0 VSTO 2005 (early thinking) O12-specifics : new features, file format, UI App-level add-ins for most client programs Deeper server side programming Excel User-Defined Funcs (client/server) Workflow & SharePoint support Mobile device support Custom ActionsPane Host Controls on the document surface Cached Data in the document Server-side data processing App-level add-ins for Outlook Manifest-based deployment & update VSTO 2003 Document-level code behind Brings Office into the managed world Strict security model
更多的 Office 开发向导
Host Controls Bookmark Bookmark XmlNode XmlNode NamedRange Range ListObject List ChartObject Chart First class .NET object extending Office object model types Custom Ribbon Extensions Core Tasks Task Panes Inherits members of underlying object Enhanced functionality New events Data binding support Resolution of Event/Method Collisions Tag field & Parameterized Property Fix for C#
Windows Forms Controls Use normal Windows controls in Word documents and Excel spreadsheets Embedded in VSTO-defined ActiveX container Custom Ribbon Extensions Core Tasks Task Panes
数据绑定 Databinding Builds on ADO.NET Program against data instead of Word and Excel object models Bind multiple controls to same DataSet Two types of binding Simple (Binding a field to the property of a view control) Complex (Binding multiple field values to a control) Data sources include: Web Service Database DataSet Custom Object Custom Ribbon Extensions Core Tasks Task Panes
创建一个 VSTO Word 2007 项目,使用 Host control 和 Windows Control 来进行数据绑定
定制 Office 2007 用户界面 Scenarios ISV with ERP solution can create application-wide ribbon extensions that allow users to access their information from within all Office 2007 products that support the new UX Custom Ribbon Extensions Core Tasks Add your own tabs Add your own groups to built-in tabs Add to the File menu Add to built-in contextual tabs Task Panes
Ribbon Components Review Ribbon accessible via a tab A Ribbon contains one or more groups A group contains one or more controls New controls: ToggleButtons, SplitButtons, EditBoxes, DropDowns, ComboBoxes, CheckBoxes, DropDownGrids Custom Ribbon Extensions Core Tasks Task Panes
Ribbon XML File Architecture ribbon tabs tab Custom Ribbon Extensions Core Tasks Task Panes group control group control
Document-Level Custom UI Steps 1. Create ribbon XML file 2. Open Office 2007 zip package 3. Add ribbon XML file to zip package 4. Add new content type Override PartName "/customui/customui.xml“ ContentType "application/xml"/ 5. Add new relationship Relationship Id "rId*“ Type "http://schemas.microsoft.com/office/2006/relationships/ui/extensibility" Target "customui/customui.xml"/ 6. Package back again as Office 2007 document Custom Ribbon Extensions Core Tasks Task Panes
Action Handlers Create procedure (VBA or .NET) Sub YourActionHandlerProcedure(ByVal control As Variant) Your Code End Sub Hook it up with the control in the ribbon button id "buttonGenerateRefNumber" label "Reference Number" XML size "large" onAction “YourActionHandler"/ Custom Ribbon Extensions Core Tasks Task Panes
给一个文档增加一个自定义 Ribbon
定制 Office 2007 客户端的界面 Your options Document-level (static) Specific Doc/Template Include custom UI in the file package Make action handlers available in Visual Basic for Applications (VBA) Application-level (dynamic) Load custom UI via add-in Make action handlers available in add-in Doc Parts Core Tasks Task Panes Action Handlers Any Document Action Custom UI Handlers Add-In Custom Ribbon Extensions Custom UI
定制任务面板 ( Task Panes ) Scenarios ISV creating a smart document Custom Ribbon Extensions solution for helping a sales person creating a sales proposal Core Tasks ISV creating a task pane that can be activated by the user in order for him to access the ISV specific information (e.g. from a back-end financial LOB system) Task Panes
创建一个文档级别的任务面板
Microsoft 2007 Office System 开发展 望 Collaboration Portals Content management Search Streamlined Business processes intelligence Word processing Business modeling Business data Presentations managemen t Information Management