int ExportDataGrid(Stream stream, UnicontaBaseEntity[] corasauBaseEntity, Dictionary <string, int> mappedItems) { Type RecordType; if (corasauBaseEntity.Length > 0) { RecordType = corasauBaseEntity[0].GetType(); } else { return(0); } var Props = new List <PropertyInfo>(); var Headers = new List <string>(); var sortedItems = (from l in mappedItems where l.Value > 0 orderby l.Value ascending select l).ToList(); foreach (var strKey in sortedItems) { var pInfo = RecordType.GetProperty(strKey.Key); if (pInfo != null) { Headers.Add(UtilFunctions.GetDisplayNameFromPropertyInfo(pInfo)); Props.Add(pInfo); } } int cnt = 0; #if !SILVERLIGHT var writer = new StreamWriter(stream, Encoding.Default); cnt = CSVHelper.ExportDataGridToExcel(stream, Headers, corasauBaseEntity, Props, spreadSheet, ".xlsx", "Intrastat"); writer.Flush(); #endif return(cnt); }