Beispiel #1
0
        public static int WriteBody(StreamWriter sw, DbDataReader r, string separator, string dateTimeFormat, int?roundFloatsTo)
        {
            int linesWritten = 0;

            while (r.Read())
            {
                //write values
                for (int i = 0; i < r.FieldCount; i++)
                {
                    //clean string
                    sw.Write(CSVOutputFormat.CleanString(r[i], separator, out _, dateTimeFormat, roundFloatsTo));
                    if (i < r.FieldCount - 1)
                    {
                        sw.Write(separator); //if not the last element add a ','
                    }
                    else
                    {
                        sw.WriteLine();
                    }
                }
                linesWritten++;
            }

            return(linesWritten);
        }
Beispiel #2
0
 public static void WriteHeader(StreamWriter sw, DbDataReader r, string separator, string dateTimeFormat)
 {
     //write headers
     for (int i = 0; i < r.FieldCount; i++)
     {
         sw.Write(CSVOutputFormat.CleanString(r.GetName(i), separator, out _, dateTimeFormat, null));
         if (i < r.FieldCount - 1)
         {
             sw.Write(separator);
         }
         else
         {
             sw.WriteLine();
         }
     }
 }