issue with date format when exporting to excel
-
Hi, I have a grid where i have to filter the columns like multiple search filter and what ever records i get in the grid i am doing export to excel in c# Everything was went well except the date column in the grid the date column data is in this format 2014/11//15 here is my c# code which i am using to remove special characters private void getfilterdata(string filter, out string key, out string val) { key = string.Empty; val = string.Empty; if (!string.IsNullOrEmpty(filter)) { string[] retval2 = filter.Split(new string[] { "data" }, StringSplitOptions.RemoveEmptyEntries); if (retval2 != null && retval2.Count() > 1 && !string.IsNullOrEmpty(retval2[1])) { string[] strkeys = retval2[0].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries); if (strkeys.Length >= 3 && !string.IsNullOrEmpty(strkeys[3])) { key = strkeys[3]; val = RemoveSpecialCharacters(retval2[1]); } } } } In the key its shows column name and in the val it shows data.. in the val i am getting data as 20141115. So its not matching and while exporting its empty i am not getting any records becaus e of this this is my code for RemoveSpecialCharacters public static string RemoveSpecialCharacters(string str) { return Regex.Replace(str, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled); } Any help plz.....
-
Hi, I have a grid where i have to filter the columns like multiple search filter and what ever records i get in the grid i am doing export to excel in c# Everything was went well except the date column in the grid the date column data is in this format 2014/11//15 here is my c# code which i am using to remove special characters private void getfilterdata(string filter, out string key, out string val) { key = string.Empty; val = string.Empty; if (!string.IsNullOrEmpty(filter)) { string[] retval2 = filter.Split(new string[] { "data" }, StringSplitOptions.RemoveEmptyEntries); if (retval2 != null && retval2.Count() > 1 && !string.IsNullOrEmpty(retval2[1])) { string[] strkeys = retval2[0].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries); if (strkeys.Length >= 3 && !string.IsNullOrEmpty(strkeys[3])) { key = strkeys[3]; val = RemoveSpecialCharacters(retval2[1]); } } } } In the key its shows column name and in the val it shows data.. in the val i am getting data as 20141115. So its not matching and while exporting its empty i am not getting any records becaus e of this this is my code for RemoveSpecialCharacters public static string RemoveSpecialCharacters(string str) { return Regex.Replace(str, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled); } Any help plz.....
Are you using the Grid functions to export the content of the grid or are you exporting the underlying collection. If it is the grid then you should get the grid to reformat the date then export the data. If you are exporting the underlying collection then it is just a matter of formatting the underlying DateTime data object. The most unambiguous format I have found to bd dd/MMMM/yyyy.
Never underestimate the power of human stupidity RAH
-
Hi, I have a grid where i have to filter the columns like multiple search filter and what ever records i get in the grid i am doing export to excel in c# Everything was went well except the date column in the grid the date column data is in this format 2014/11//15 here is my c# code which i am using to remove special characters private void getfilterdata(string filter, out string key, out string val) { key = string.Empty; val = string.Empty; if (!string.IsNullOrEmpty(filter)) { string[] retval2 = filter.Split(new string[] { "data" }, StringSplitOptions.RemoveEmptyEntries); if (retval2 != null && retval2.Count() > 1 && !string.IsNullOrEmpty(retval2[1])) { string[] strkeys = retval2[0].Split(new char[] { '"' }, StringSplitOptions.RemoveEmptyEntries); if (strkeys.Length >= 3 && !string.IsNullOrEmpty(strkeys[3])) { key = strkeys[3]; val = RemoveSpecialCharacters(retval2[1]); } } } } In the key its shows column name and in the val it shows data.. in the val i am getting data as 20141115. So its not matching and while exporting its empty i am not getting any records becaus e of this this is my code for RemoveSpecialCharacters public static string RemoveSpecialCharacters(string str) { return Regex.Replace(str, "[^a-zA-Z0-9_.]+", "", RegexOptions.Compiled); } Any help plz.....