일반 토론

  • In this post, we are listing quite some topics that have been discussed in the past. We also list the links to the best known solutions. We will continue add more topic to the list going forward.


         1.          How many versions of Open XML Format SDK are there and which version is available in your solution?

    §  So far, there have been two versions of Open XML Format SDK: V1 (1.0) and V2 (2.0). V1 is a product version, which can be redistributed in your solution, while V2 is still in CTPs without a RTW version product license, so it cannot be redistributed.

    §  The latest version is Open XML Format SDK 2.0 August 2009 CTP for Microsoft Office, for more information about the product, please download it and see “OpenXMLSDK.chm” file in it.

         2.          How to generate document from database based on document template?

    Blog post link

         3.          How to convert Office binary documents to OOXML documents?

    §  Install Microsoft Office Compatibility Pack for Word, Excel and PowerPoint 2007 File Formats, then you can save the binary documents as OOXML documents.

    §  Use B2XTranslator tool developed by Microsoft Interoperability team.

         4.          How to transform OOXML documents using XSLT?

    Blog post link

         5.          How to convert XML documents to OOXML documents?

    Article link

         6.          How to insert HTML chunk into OOXML document while keeping the formats?

    §  Forum discussion thread about using AltChunk.

    §  If AltChunk causes error, converting OOXML documents to flat OPC would be a workaround.

         7.          How to embed PDF or arbitrary binary documents in OOXML documents?

    §  You need to firstly know what’s the OLE objects in OOXML documents, and how does OOXML store OLE Objects: online tutorial

    §  A specific example of embedding PDF: blog post link

         8.          How to update multiple external data connections in Excel?

    MSDN article

         9.          How to embed custom data in the custom XML part in to Word document by using content control?

    Blog post link

      10.          How to merge several documents into one document by using AltChunk?

    Blog post link

      11.          How to merge multiple PPT slides?

    Blog post link

      12.          How to generate TOC (table of contents) in Word document?

    Forum discussion thread link

      13.          How to update TOC (table of contents) dynamically in Word document?

    Creating a TOC requires layout engine in order to determine page numbers, but SDK does not perform such layout functionality. There is a workaround here to let Word update the TOC for you.

    Forum discussion thread link

      14.          How to automatically recalculate the formula value for cells in Spreadsheet?

    A cell with a formula will store the cached value in the markup and show the cached value as the result. If the cell value referenced by the formula is changed programmatically, the cell with the formula has no idea of that change. The cached value of this formula is then obsolete, and should be updated. The automatic recalculation requires runtime layout functionality, which is not supported in the SDK. The workaround for this situation is to: delete the cached value of the formula cell, and then invoke Excel to recalculate the value for you at backend. The Excel service could help here.

      15.          How to add passwords to OOXML document via the SDK?

    The SDK uses System.IO.Packaging API to unzip the OOXML package, which is fundamentally a .zip package. The current design of the SDK cannot either decode an encrypted OOXML package or add passwords to OOXML documents. You may leverage automation or server-side service to implement this requirement.

      16.          How to generate a valid document?

    After you use the SDK to generate a document programmatically, sometimes you unluckily find that the document cannot be consumed by Office application, and Office application does not offer enough/informative indication to tell you what the problem is. In Open XML Format SDK 2.0 August 2009 CTP for Microsoft Office , there’s a new feature called Validation, which is designed to help the developers find out the errors, understand them and solve them. Here’s a tutorial talking about this feature.

      17.          How to extend Fluent UI by Ribbon customization?

    Blog post link to tools and resources about fluent UI extensibility.

    Blog post link to how to extend fluent UI by SDK.

      18.          How to use Silverlight technology to view .docx documents in browser?

    An introduction of TextGlow

      19.          The Halloween problem in using LINQ.

    You should not update (change/delete) elements when you iterate them in DOM tree in a foreach statement. See more information about Halloween problem.


    2009년 8월 11일 화요일 오전 2:41

모든 응답

  • Several places in the above text you mention the april CTP. Although the link point to the august CTP, you probably want to change the text accordingly.
    2009년 9월 1일 화요일 오전 6:27
  • good catch. when the FAQ was posted, there was only April CTP download. The August CTP now is live and is sharing the same download site. Thanks for pointing it out. I will edit it accordingly.
    2009년 9월 1일 화요일 오전 10:04
  • I was looking for a solution to #14.  Here is what I used initially to delete all cached values for cells with formulas.  It can probably be simplified or made better, but it works for me:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using DocumentFormat.OpenXml;
    using DocumentFormat.OpenXml.Packaging;
    using DocumentFormat.OpenXml.Spreadsheet;
    namespace MyNamespace
        public class MyOpenXmlSpreadsheet : IDisposable
            #region Member Data
            SpreadsheetDocument spreadsheetDocument;
            bool isEditable = false;
            public MyOpenXmlSpreadsheet(string path, bool isEditable)
                this.isEditable = isEditable;
                spreadsheetDocument = SpreadsheetDocument.Open(path, isEditable);
                // the open xml sdk does not have support for recalculating formulas.  It has to be done manually.
                if (isEditable)
            private void RemoveAllCachedFormulaValues()
                foreach(Worksheet worksheet in GetAllWorksheets())
                    foreach(Cell cell in GetAllCellsInWorksheet(worksheet))
                        if (cell.CellFormula != null)
                            if (cell.CellValue != null)
            private IEnumerable<Worksheet> GetAllWorksheets()
                ICollection<Worksheet> allWorksheets = new HashSet<Worksheet>();
                // loop through all worksheets
                foreach (Sheet sheet in spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>())
                return allWorksheets;
            private IEnumerable<Cell> GetAllCellsInWorksheet(Worksheet worksheet)
                ICollection<Cell> allCellsInWorksheet = new HashSet<Cell>();
                SheetData sheetData = worksheet.GetFirstChild<SheetData>();
                foreach(Row row in sheetData.Elements<Row>())
                    foreach(Cell cell in row.Elements<Cell>())
                return allCellsInWorksheet;
    2010년 4월 13일 화요일 오후 6:43
  • #12 - are you serious? There is no pointer, link or information in any other form about how to generate a table of contents. The given link only gives a non-descriptive solution to two specific problems that occur after you managed to create the TOC.
    2010년 9월 20일 월요일 오전 9:38
  • Hi,

    how to create new columns in existing excel sheet that is saved in sharepoint document library,am trying with open xml sdk but not getting any solution.

    2013년 6월 25일 화요일 오전 6:16