none
Changing a Cells format with OpenXML SDK 2.0 RRS feed

  • Question

  • I've looked at other posts but I'm getting confused, so I thought I would ask. I have an Excel Spreadsheet that I have to apply a date format to 2 columns before I open/read it with an odbc connection. I used to use the Excel Interop to do this, but now I have to use Open XML. I'm using SDK 2.0. How can I open an Excel workbook, select a specific sheet and then change the format of columns F & G to the predefined date format mm/dd/yyyy?
    Thursday, December 20, 2012 4:27 PM

Answers

  • Hi Whalensdad,

    Thanks for posting in the MSDN Forum.

    I think I must declare this point before we discuss your issue: Open Xml will not handle Open Event of Microsoft Excel. You are able to use Open Xml to create , modify Excel spreadsheet document via program before you open it.

    For your issue I think you need to create a NumberingFormat under WorkbookStylePart.Stylesheet. Before your created it, I would recommend you check whether your document have customized number format already. As usual, the NumberFormatId which is assigned to your number format is begin at 164. Then you need create a CellFormat under the WorkbookStylePart.Styplesheet.Cellformates and implement your number format via NumberFormatId. At the end, you need implement your CellFormat for all target cells via this index of the cellformat.

    I hope what I said can help you.

    Have a good day,

    Tom


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, December 21, 2012 1:58 AM
    Moderator