/// <summary> /// Returns a character formatted string for display purposes from the contents of the IDataReader. This means that the DataReader will be /// unusable after because it will have already been read through (DataReader's being forward only). /// </summary> /// <param name="dr"></param> /// <param name="formatted"> /// Whether or not the string should be formatted and lined up with spaces. Setting this value as false will /// return just a delimited file. /// </param> /// <param name="fieldDelimiter"></param> /// <param name="exportHeader"></param> public static string ToString(this IDataReader dr, bool formatted, string fieldDelimiter, bool exportHeader) { var cdf = new CreateDelimitedFile(exportHeader, fieldDelimiter); string buf = cdf.ToString(dr); return(formatted ? StringTransforms.FormatDelimitedString(buf, "\t") : buf); }
/// <summary> /// Exports the contents of the DataTable to a delimited string. /// </summary> /// <param name="dt"></param> /// <param name="exportHeader">Whether or not to export the name of the columns in the header row.</param> /// <param name="delimiter">The value to place in between the individual fields, typically something like a tab.</param> public static object ToString(this DataTable dt, bool exportHeader, string delimiter) { var ff = new CreateDelimitedFile(exportHeader, delimiter); return(ff.ToString(dt)); }
/// <summary> /// Returns a delimited string with the contents created from the IDataReader. This means that the DataReader will be /// unusable after because it will have already been read through (DataReader's being forward only). /// </summary> /// <param name="dr"></param> /// <param name="fieldDelimiter"></param> public static string ToString(this IDataReader dr, string fieldDelimiter) { var cdf = new CreateDelimitedFile(false, fieldDelimiter); return(cdf.ToString(dr)); }