Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
470
Excel date format string not applied
posted

Hi,

I have been trying to set the date format to worksheet cell but it not working. Here's what i have - 

row.Cells[columnIndex].CellFormat.FormatString = "mm/dd/yyyy h:mm AM/PM";
row.Cells[columnIndex].CellFormat.Alignment = HorizontalCellAlignment.Right;

Due to this the filter does not work as expected. The column is considered as a text - 

But the same when i do by opening the Excel from my system and then set the format, the column is correctly set as Date and the filter looks like below - 

The one in the second image is the expected outcome.

Can you please help me fix this ?

Parents
  • 21795
    Offline posted

    Hello Vaishnavi,

    Following the steps you described I have created a small sample website with a single grid. Then I have exported the grid with WebExcelExporter, have set the FormatString of the date column as you did. In the exported Excel file the format of the column is correct in my sample.

    I am sending you my sample to test it on your side. Please run it and let me know what the result of this test is.

    Looking forward to your reply.

    webGridToExcel.zip

Reply Children