예제 #1
0
파일: CSV.cs 프로젝트: PcloD/DotaAffair
        public static void WriteToStream(this DataTable dt, StreamWriter sw, bool save_column_names, char delim = DEFAULT_DELIMITER, char qual = DEFAULT_QUALIFIER)
#endif
        {
            using (CSVWriter cw = new CSVWriter(sw, delim, qual)) {
                cw.Write(dt, save_column_names);
            }
        }
예제 #2
0
 /// <summary>
 /// Write the data table to a stream in CSV format
 /// </summary>
 /// <param name="dt">The data table to write</param>
 /// <param name="sw">The stream where the CSV text will be written</param>
 /// <param name="settings">The CSV settings to use when exporting this DataTable (Default: CSV)</param>
 public static void WriteToStream(this DataTable dt, StreamWriter sw, CSVSettings settings = null)
 {
     using (CSVWriter cw = new CSVWriter(sw, settings))
     {
         cw.Write(dt);
     }
 }
예제 #3
0
파일: CSV.cs 프로젝트: PcloD/DotaAffair
        public static string WriteToString(this DataTable dt, bool save_column_names, char delim = DEFAULT_DELIMITER, char qual = DEFAULT_QUALIFIER)
#endif
        {
            using (var ms = new MemoryStream()) {
                var sw = new StreamWriter(ms);
                var cw = new CSVWriter(sw, delim, qual);
                cw.Write(dt, save_column_names);
                sw.Flush();
                ms.Position = 0;
                using (var sr = new StreamReader(ms)) {
                    return(sr.ReadToEnd());
                }
            }
        }
예제 #4
0
 /// <summary>
 /// Write a DataTable to a string in CSV format
 /// </summary>
 /// <param name="dt">The datatable to write</param>
 /// <param name="settings">The CSV settings to use when exporting this DataTable (Default: CSV)</param>
 /// <returns>The CSV string representing the object array.</returns>
 public static string WriteToString(this DataTable dt, CSVSettings settings = null)
 {
     using (var ms = new MemoryStream())
     {
         var sw = new StreamWriter(ms);
         var cw = new CSVWriter(sw, settings);
         cw.Write(dt);
         sw.Flush();
         ms.Position = 0;
         using (var sr = new StreamReader(ms))
         {
             return(sr.ReadToEnd());
         }
     }
 }
예제 #5
0
        public static string WriteToString(this DataTable dt, CSVSettings settings = null)
#endif
        {
            if (settings == null)
            {
                settings = CSVSettings.CSV;
            }
            using (var ms = new MemoryStream())
            {
                var cw = new CSVWriter(ms, settings);
                cw.Write(dt);
                var rawString = settings.Encoding.GetString(ms.ToArray());
                return(CSV.RemoveByteOrderMarker(rawString));
            }
        }