none
How to insert a cell with a format style? RRS feed

  • Question

  • I am generating excel 2007 docs with OPENXML SDK CTP 2.0 AUG.
    It works okay. But I insert my datetime value as oadate, datatype = cellvalues.Number.
    it insert the correct value but without any format.
    I only know it has something to do with style.xml and numFmt
    Could someone tell me how to do it with the SDK?   (no hard code.)
    Friday, December 11, 2009 9:59 AM

Answers

  • Thanks for your question.

    You are correct. To fomrat a cell, you need to and numFmt in style.xml. The best way to learn how to format a cell with the SDK is to use the Productivity Tool released with OpenXML SDK 2.0 Dec CTP. You can download it from http://www.microsoft.com/downloads/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en 

    The productivity tool in this release has the functionalities to compare two office documents in Open XML Level (Open XML Diff), Reflect an office document to corresponding C# code using SDK (Document Reflector), and Generating C# code with SDK to reflect the differences between two office doucments (Code For Diff).

    In your case, you can create an empty excel document as the source document, then format a cell with desired format and save as the target document. Comparing two documents with the productivity tool's Open XML Diff function to see which open xml part/elements you need to change. Or you can use the Code For Diff function to generate C# code for the difference between your source and target documents.

    By either way, you should be able to create/apply a style to a cell.

    Thanks

    Yong
    • Marked as answer by Maxi Ng Monday, December 14, 2009 2:58 AM
    Monday, December 14, 2009 2:36 AM