Download source files - 2 Kb
Introduction
ASP.Net and .net framework provides many ways to deal with Data , many times in web scenario , we need to export data back to user , this scenario ranges from Some custom addressbook entries to custom lists and other complex transaction details , which are a result of persistant data or dta in memory.
Background
Lots of code piece were used to export dataset into file formats,this functions can be a good way to START in this format exporting path...Using the Code
The code contains 2 function and an enum.
the functions are
public static void ExportDataSet(DataSet dsResults , ExportFormat enExport,string strColDelim, string strRowDelim, string strFileName)
and
public static string ParseToDelim(string strText, string strRowDelim , string strColDelim)
This functions uses popular regular expressions to deal with trimming , stripping of data.
Code Snippet
public static string ParseToDelim(string strText, string strRowDelim , string strColDelim)
{
Regex objReg = new Regex(@"(>\s+<)",RegexOptions.IgnoreCase);
strText = objReg.Replace(strText,"><");
strText = strText.Replace(System.Environment.NewLine,"");
strText = strText.Replace("</td></tr><tr><td>",strRowDelim);
strText = strText.Replace("</td><td>",strColDelim);
objReg = new Regex(@"<[^>]*>",RegexOptions.IgnoreCase);
strText = objReg.Replace(strText,"");
strText = System.Web.HttpUtility.HtmlDecode(strText);
return strText;
}
Steps
Step 1
Copy this Code in a CS Class. and add it to a web project
Step 2
add a BLANK web page (with just @page directive) and call the function with required parameter in page_load
About me
I am Brijesh Pandya , a Developer in .Net , I work on area like SEO,ASP.net and Blogging
http://brip.blogspot.com
http://spaces.msn.com/members/brip/
http://groups.yahoo.com/group/itsdifferent/join