Example #1
0
 public void SaveAsCSV(CSVTable nDataTable, MemoryStream nCSVStream, bool nAutoTrim, bool nHasHeader, string nSeparator, string nTextQualifier)
 {
     this.TextQualifier = nTextQualifier;
     SaveAsCSV(nDataTable, nCSVStream, nAutoTrim, nHasHeader, nSeparator);
 }
Example #2
0
 internal CSVColumnList(CSVTable nTable)
 {
     this.ColumnsDictionary = new Dictionary <string, CSVColumn>();
     this.ColumnsList       = new List <CSVColumn>();
     this.Table             = nTable;
 }
Example #3
0
 public void SaveAsCSV(CSVTable nDataTable, MemoryStream nCSVStream, bool nAutoTrim, bool nHasHeader)
 {
     this.HasHeader = nHasHeader;
     SaveAsCSV(nDataTable, nCSVStream, nAutoTrim);
 }
Example #4
0
 public void SaveAsCSV(CSVTable nDataTable, string nCSVFile, bool nAutoTrim, bool nHasHeader, string nSeparator)
 {
     this.Separator = nSeparator;
     SaveAsCSV(nDataTable, nCSVFile, nAutoTrim, nHasHeader);
 }
Example #5
0
 public void SaveAsCSV(CSVTable nDataTable, string nCSVFile, bool nAutoTrim, bool nHasHeader)
 {
     this.HasHeader = nHasHeader;
     SaveAsCSV(nDataTable, nCSVFile, nAutoTrim);
 }
Example #6
0
        public void SaveAsCSV(CSVTable nDataTable, string nCSVFile, bool nAutoTrim)
        {
            SetupRegEx();

            var sLine = "";
            var sw    = new StreamWriter(nCSVFile, false, this.SaveEncoding);

            if (this.HasHeader)
            {
                for (var iCol = 0; iCol < nDataTable.Columns.Count; iCol++)
                {
                    if (!nDataTable.Columns[iCol].Export)
                    {
                        continue;
                    }
                    if (sLine.Length > 0)
                    {
                        sLine += this.Separator;
                    }

                    sLine += ExportFormat(nDataTable.Columns[iCol].ColumnTitle);
                }

                sw.WriteLine(sLine);
            }

            foreach (CSVRow dr in nDataTable.Rows)
            {
                sLine = "";

                for (var iCol = 0; iCol < nDataTable.Columns.Count; iCol++)
                {
                    if (!nDataTable.Columns[iCol].Export)
                    {
                        continue;
                    }

                    if (iCol > 0)
                    {
                        sLine += this.Separator;
                    }

                    if (dr[iCol] == null)
                    {
                        continue;
                    }

                    var Valor = ExportFormat(getValueFormated(dr[iCol], nDataTable.Columns[iCol].Format));

                    if (Valor.IndexOf(this.Separator) > -1)
                    {
                        sLine += this.TextQualifier + (nAutoTrim ? Valor.Trim() : Valor) + this.TextQualifier;
                    }
                    else
                    {
                        sLine += (nAutoTrim ? ExportFormat(Valor.Trim()) : Valor);
                    }
                }

                sw.WriteLine(sLine);
            }

            sw.Flush();
            sw.Close();
        }
Example #7
0
 internal CSVRowList(CSVTable nTable)
 {
     this.Rows  = new List <CSVRow>();
     this.Table = nTable;
 }