Пример #1
0
        /// <summary>
        /// Save data from table to CSV file
        /// </summary>
        /// <param name="path">Path to file</param>
        /// <param name="s">Data from rows of table</param>
        /// <param name="c">CSV or another separator</param>
        /// <param name="rewrite">Rewrite or append</param>
        public static void SaveStrtoCSV(string path, System.Windows.Forms.DataGridViewRowCollection s, char c = ',', bool rewrite = false, Encoding encode = null, string header = "")
        {
            if (header == "")
            {
                header = "ROWNUM" + c + "Name" + c + "OPOPNumber" + c + "AdmArea" + c + "District" + c + "Address" + c + "PublicPhone" + c + "ExtraInfo" + c + "X_WGS" + c + "Y_WGS" + c + "GLOBALID";
            }
            List <string> se = new List <string>();

            se.Add(header);
            for (int i = 0; i < s.Count - 1; i++)
            {
                if (s[i] == null)
                {
                    continue;
                }
                if (s[i].Visible)
                {
                    se.Add(ConvertListstrtoCSVline(s[i].Cells, c));
                }
            }
            try
            {
                fprintf(path, se.ToArray(), rewrite, encode);
            }
            catch (CSVException e)
            {
                throw e;
            }
            catch (Exception e)
            {
                throw new CSVException(null, e);
            }
        }
Пример #2
0
 public void setNewPath(System.Windows.Forms.DataGridViewRowCollection rows)
 {
     this.newPath = this.path.ToLower();
     for (int i = 0; i < rows.Count; i++)
     {
         if (rows[i].Cells[0].Value != null && rows[i].Cells[1].Value != null)
         {
             this.newPath = this.newPath.Replace(rows[i].Cells[0].Value.ToString().ToLower(), rows[i].Cells[1].Value.ToString().ToLower());
         }
     }
 }
Пример #3
0
 public static IEnumerable <System.Windows.Forms.DataGridViewRow> AsEnumerable(this System.Windows.Forms.DataGridViewRowCollection source)
 {
     TypeCheckEnumerable(source, (s) => s.AsEnumerable(), (s) => s[0]);
     return(source.Cast <System.Windows.Forms.DataGridViewRow>());
 }
Пример #4
0
 public static IList <System.Windows.Forms.DataGridViewRow> AsIList(this System.Windows.Forms.DataGridViewRowCollection source)
 {
     return(IListWrapper.Get(source, s => s[0]));
 }