Problem with Format method

Posted by: matteo.nava on 29 August 2018, 2:31 am EST

    • Post Options:
    • Link

    Posted 29 August 2018, 2:31 am EST

    I have to extract a DataGridView into an Excel file. Into my DataGrid I have got CurrentDate, amongst other datas, and I want that the date’s format is “dd/mm/yyyy”.

    I saw this document http://help.grapecity.com/componentone/PDF/WPF/WPF.Excel.pdf and I tried to use this instruction ```

    style.Format = “dd-MM-yyyy”;

    
    I have to use necessarily old libraries, is this the problem?
    In case exists a similar way to set my date format?
  • Posted 29 August 2018, 4:56 pm EST

    Hello,

    For your requirement of exporting C1DataGrid’s data to excel there are there are essentially two things you can do:

    1. Directly export the C1DataGrid to excel format using its Save method. Using this approach, you have the option of keeping/ignoring the format/styles while exporting.
    2. Load C1DataGrid’s data in excel sheet using C1.WPF.Excel. Using this approach, you may apply any style to any cell while loading data in sheet.

      I have attached a sample application implementing both the approaches for your reference.

    >> I have to use necessarily old libraries, is this the problem?

    What ComponentOne version are you using?

    Thanks,

    Ruchir

    Excel_DataGrid.zip

  • Posted 29 August 2018, 8:31 pm EST

    Thanks for your reply. I’m using the version 2.6.20103.54202.

    I can’t ignore the formate, because normally is ‘mm/dd/yyyy’ and I want ‘dd/mm/yyyy’.

    I have tried to use the second approch, but I haven’t got methods Font, BackColor and Format.

    Is correct with my version or I’m doing wrong something?

    I have added the following references: C1.C1Excel.2, C1.C1Report.2, C1.Win.C1Report.2 and C1.Win.C1TrueDBGrid.2.

    Instead, as regards the libreries, I have added C1.WPF.DataGrid.Excel and C1.WPF.Excel.

  • Posted 30 August 2018, 4:47 pm EST

    Hello,

    I meant what WPF ComponentOne version are you using ?

    Also, just to avoid any confusion could you please confirm whether your application is targeting WinForms or WPF. And whether you are using C1TrueDbGrid/ C1DataGrid or MS-DataGridView?

    Furthermore, if you are using WPF+C1DataGrid then you may refer C1.WPF.Excel.4 assembly in your project in order to use C1Excel features of saving and formatting while saving.

    I also modified the earlier sample to include DateTime fields and attached here for your reference.

    Thanks,

    Ruchir

    WPF_C1ExcelC1DataG.zip

  • Posted 30 August 2018, 8:34 pm EST

    I have done some checks into your code. Unfortunately I haven’t C1.WPF.Excel.4 dll and I can’t take it for a license problem. Is there a way with the librieries and dll that I have to resolve my problem?

  • Posted 2 September 2018, 10:16 pm EST

    Hello,

    We created a Support case:341739 for you. To continue our discussion we request you to kindly revert there.

    Thanks,

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels