I am using Infragistics.Controls.Grids.XamGrid in a silverlight application. I am using the assembly-
clr-namespace:Infragistics.Controls.Grids;assembly=InfragisticsSL5.Controls.Grids.XamGrid.v14.2.
I am exporting the grid data using Infragisitcs.Documents.Excel.WorksheetCell class, after export date column is not recognized automatically in exported excel sheet.
After applying filter on date column in exported excel sheet, I do not find "Date Filters", it is still there as "Text Filters"
As date column is not recognized as date in exported excel sheet then the sorting can be wrong and we cannot drill down the filter in excel (year -> month -> date)
Appreciate if any one answers with some hints or solution.
My code sample is as below for reference:
string format = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;
SetCellValue(sheetOne.Rows[rowIndex].Cells[currentCell],(cell.Row.Data as IGenericDomainObjectWrapper).GetValue(cell.Column.Key), format);
void SetCellValue(WorksheetCell cell, object value, string format = "")
{
cell.Value = TryParseDate(value.ToString(), format);
cell.CellFormat.FormatString = Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern;
cell.CellFormat.ShrinkToFit = ExcelDefaultableBoolean.False;cell.CellFormat.VerticalAlignment = VerticalCellAlignment.Center;cell.CellFormat.Alignment = HorizontalCellAlignment.Left;
}
Hello,
I am glad that you have managed to find a reasonable solution.
I will close this case. Please note that closed cases may be reopened within thirty days of closure.
Thank you for using Infragistics Components.
Regards,
Stefana
, I will close this case. Please note that closed cases may be reopened within thirty days of closure.
Thank you for using Infragistics Components
Thanks for follow-ups!
I found the solution by converting cell value to exact date time format by using DateTime.ParseExact(date.ToString(format), format, provider) as below:
cell.Value = TryParseExactDate(value.ToString(), format);
cell.CellFormat.FormatString = format;
public static DateTime TryParseExactDate(string dateString, string format = "")
try
DateTime date = Convert.ToDateTime(dateString);
CultureInfo provider = Thread.CurrentThread.CurrentCulture;
DateTime result = DateTime.ParseExact(date.ToString(format), format, provider);
return result;
catch (Exception)
return DateTime.MinValue;
Now I able to sort Oldest to Newest and Newest to Oldest in excel.
I am able to drill down the filter in excel (year-> month-> date->).
Hi,
I'm just checking your progress. If you have any questions, feel free to ask!
Have a look at the attached sample.
Feel free to make any modifications that will help to reproduce the described behavior, so that I can go deeper and find a solution.
Thanks Stefana for reply.
We can not take up the approach using IG XamGridExcelExporter at this stage.
Is it possible to get solution through my above mentioned c# code (i.e., implemented in our application) using Infragisitcs.Documents.Excel.WorksheetCell class?
We want below things after applying in excel:- Select exported date column-> click on Data tab in excel sheet-> click on Filter button-> click on dropdown icon to apply filter and sort on exported date column->
1. We should be able to sort Oldest to Newest and Newest to Oldest in excel.
2. We should be able to drill down the filter in excel (year-> month-> date->).
3. We should be able to find the name of filter as "Date Filters" .
Anand Sinha