微软公司昨天发布的三个与Office System 2007相关的软件和参考文档

随着Office System 2007的发布,微软公司的新一代企业业务平台变得前所未有的强大。Office相关开发也正逐渐变得炙手可热。为了帮助开发者更好地了解并基于Office System 2007进行开发,微软公司将发布一系列有关Office System 2007的参考文档以及相关辅助软件。

昨天微软公司就发布了如下三个与Office System 2007相关的软件和参考文档:

 

[1] 2007 Office System Document: Compliance Features in the 2007 Microsoft Office System

下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=d64dfb49-aa29-4a4b-8f5a-32c922e850ca&DisplayLang=en

这篇洋洋洒洒的67页的文档全面介绍了Office System 2007的适应性以及扩展性能力。每一个应用了Office System 2007的企业都将会有它自己的个性化、需要定制的需求。这份文档就将告诉我们Office System 2007开发者什么样的需求是能够实现的,应该怎样实现等相关内容。文档份为如下几大部分:

  1. Introduction
  2. An Overview of Regulatory Compliance
  3. The 2007 Microsoft Office System Products
  4. Compliance Capabilities in the 2007 Microsoft Office System
  5. Compliance Extensibility Opportunities
  6. Development Tools for Extending Office and Windows SharePoint Services
  7. Summary
  8. Appendix I: Resources
  9. Appendix II: References

如果你打算定制出一套自己的Office System 2007系统,那么这份文档绝对不容错过。

 

[2] 2007 Office System Document: Lists of Control IDs

下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=4329d9e9-4d11-46a5-898d-23e4f331e9ae&DisplayLang=en

Office System 2007的UI中引入了一个新东西——Ribbon。虽然对于这个Ribbon,使用者仁者见仁,众说纷纭,不过作为开发者,我们还是有必要赶上发展的脚步。Ribbon这个东西相关的开发也设计得独具匠心,具体内容就不详细说了,有兴趣的朋友可以先参考一下这篇MSDN文档:Customizing the Office (2007) Ribbon User Interface for Developers (Part 1 of 3) 。

微软公司发布的这个软件其实是一个自解压的压缩文件,解压后将得到24个Excel文件,其中分别列出了Office System 2007系列软件中使用的内建Ribbon的ID,方便我们开发时参考。

下图就显示了Word中内建的部分Ribbon的ID:

 

[3] 2007 Office System Sample: Open XML File Format Code Snippets for Visual Studio 2005

下载地址:http://www.microsoft.com/downloads/details.aspx?FamilyID=8d46c01f-e3f6-4069-869d-90b8b096b556&DisplayLang=en

不得不承认,随着Office System 2007的发布,Office开发变得更加简化,提供的API也更加丰富。不过由于Office System 2007本身的复杂性,对于初学者来说,掌握Office System 2007开发仍旧不是一件容易的事情。甚至对于一些最常用功能的实现都无所适从。

微软公司发布的这个Visual Studio 2005的Code Snippets集合就提供了一系列关于Office System 2007开发中经常用到的功能的代码片断。关于Visual Studio 2005的Code Snippets,其实就是一系列常用的代码片断,可以看作是一种代码级别的复用。这里不再多谈Code Snippets,如果你还不是很了解这个强大功能,请参考这篇MSDN文章:How to: Manage Code Snippets

下面就是在Visual Studio 2005中使用该Code Snippets时的界面:

如上图所示,选择了“Excel: Get sheet info”之后,Code Snippets将自动插入如下一大段代码:

public struct SheetInfo
{
    public string SheetName;
    public string SheetType;
 
    public SheetInfo(string SheetName, string SheetType)
    {
        this.SheetName = SheetName;
        this.SheetType = SheetType;
    }
}
 
public List<SheetInfo> XLGetSheetInfo(string fileName)
{
    //  Return a generic list containing info about all the sheets.        
    const string documentRelationshipType = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument";
 
    //  Fill this collection with a list of all the sheets
    List<SheetInfo> sheets = new List<SheetInfo>();
 
    using (Package xlPackage = Package.Open(fileName, FileMode.Open, FileAccess.Read))
    {
        //  Get the main document part (workbook.xml).
        foreach (System.IO.Packaging.PackageRelationship relationship in xlPackage.GetRelationshipsByType(documentRelationshipType))
        {
            //  There should only be one document part in the package. 
            Uri documentUri = PackUriHelper.ResolvePartUri(new Uri("/", UriKind.Relative), relationship.TargetUri);
            PackagePart documentPart = xlPackage.GetPart(documentUri);
 
            //  Load the contents of the workbook, which is all you 
            //  need to retrieve the names and types of the sheets:
            XmlDocument doc = new XmlDocument();
            doc.Load(documentPart.GetStream());
 
            //  Create a NamespaceManager to handle the default namespace, 
            //  and create a prefix for the default namespace:
            XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);
            nsManager.AddNamespace("default", doc.DocumentElement.NamespaceURI);
 
            //  Loop through all the nodes, retrieving the information
            //  about each sheet:
            foreach (System.Xml.XmlNode node in doc.SelectNodes("//default:sheets/default:sheet", nsManager))
            {
                string sheetName = string.Empty;
                string sheetType = "worksheet";
 
                sheetName = node.Attributes["name"].Value;
                XmlAttribute typeAttr = node.Attributes["type"];
                if (typeAttr != null)
                {
                    sheetType = typeAttr.Value;
                }
                sheets.Add(new SheetInfo(sheetName, sheetType));
            }
 
            //  There's only one document part.
            break;
        }
    }
    return sheets;
}

我们既可以直接使用这些已经生成好了的功能,也可以通过查看代码了解、学习Office System 2007的常用操作,简直爽呆了!

posted on 2006-11-29 22:31  Dflying Chen  阅读(2917)  评论(14编辑  收藏  举报