Beispiel #1
0
        public override string ToString()
        {
            string result = null;

            if (CsvTable != null)
            {
                result = GetCsvRawData(CsvTable.CreateDataReader(), ColumnList, true);
            }

            return(result);
        }
Beispiel #2
0
        /// <summary>
        ///     write the data table content into a csv file at the specified location.
        /// </summary>
        /// <param name="csvLocation">csv file output location</param>
        /// <param name="hasHeader"></param>
        /// <param name="encoding"></param>
        public void Write(string csvLocation, bool hasHeader, Encoding encoding = null)
        {
            if (encoding == null)
            {
                encoding = Encoding.UTF8;
            }

            if (CsvTable != null)
            {
                Write(CsvTable.CreateDataReader(), csvLocation, ColumnList, hasHeader);
            }
        }
Beispiel #3
0
        public byte[] ToBinary()
        {
            byte[] result = null;

            if (CsvTable != null)
            {
                var rawData = GetCsvRawData(CsvTable.CreateDataReader(), ColumnList, true);

                var encoder = new ASCIIEncoding();
                result = encoder.GetBytes(rawData);
            }

            return(result);
        }
Beispiel #4
0
 public void Append(string csvLocation)
 {
     if (CsvTable != null)
     {
         //Gets the existing data in the csv file
         var data = File.ReadAllText(csvLocation);
         //Add the data to string builder
         var sb = new StringBuilder(data);
         //Gets the data from the actual datareader
         var dataToAppend = GetCsvRawData(CsvTable.CreateDataReader(), ColumnList, false);
         //Appends the new data to string builder
         sb.Append(dataToAppend);
         //Writes the file
         File.WriteAllText(csvLocation, sb.ToString());
     }
 }
Beispiel #5
0
 public string GetCsvData(bool includeHeaders = true)
 {
     return(GetCsvRawData(CsvTable.CreateDataReader(), ColumnList, includeHeaders));
 }