How to set Column Type when using EPPlus

前端 未结 5 994
予麋鹿
予麋鹿 2021-02-02 05:12

I\'m using EPPlus to generate Excel files, in DAL I\'m populating DataTable, filling data into table, and passing table to Presentation La

5条回答
  •  醉梦人生
    2021-02-02 05:34

    To use build in excel formats, you need to pass correct string to

    sheet.Cells[1, 1].Style.Numberformat.Format 
    

    property.

    Now, somewhere later during execution, probably during serialization, EPPlus will try to match this format property with current dictionary of styles in workbook. It may depend on exact library version, but for example for EPPlust 4.1.0.0 short date key is "mm-dd-yy".

    For 4.1.0.0 you can find all hard-coded codes and keys to build in formats in:

    1. ExcelNumberFormatXml.cs, internal static void AddBuildIn(XmlNamespaceManager NameSpaceManager, ExcelStyleCollection NumberFormats) - here all of those codes are actually included into workbook, all hard-coded
    2. use debugger and check Workbook.Styles.NumberFormats enumeration (as key use ExcelNumberFormatXml.Format)
    3. use debugger and check Workbook.Styles.NumberFormats.(non public memeber)_dic for exact keys.

提交回复
热议问题