Beispiel #1
0
        void LoadCSV(string pos)
        {
            ReoMain.Worksheets.Clear();
            string[] folders = System.IO.Directory.GetFiles(pos);
            for (int i = 0; i < folders.Length; i++)
            {
                string folder  = folders[i];
                string oneInfo = System.IO.Path.GetFileName(folder);
                string ex      = System.IO.Path.GetExtension(folder);
                string name    = System.IO.Path.GetFileNameWithoutExtension(folder);

                if (ex == ".csv")
                {
                    var worksheet = ReoMain.CreateWorksheet(name);
                    ReoMain.Worksheets.Add(worksheet);
                    try
                    {
                        LoadCsv(File.OpenRead(pos + oneInfo), worksheet);
                    }
                    catch (Exception d)
                    {
                        EdLib.AskMsg("读取资料库时发生严重异常,错误信息:\n" + d.ToString() + "\n" + d.Message);
                    }
                    //EdLib.AskMsg("Worksheets.Count = " + ReoMain.Worksheets.Count);
                }
            }
        }
        public void WorkSheedName(bool Update)
        {
            if (Update == false)
            {
                for (int i = reoGridControl.Worksheets.Count - 1; i >= 0; i--)
                {
                    reoGridControl.RemoveWorksheet(i);
                }

                var sheet  = reoGridControl.CurrentWorksheet;
                var sheeds = new List();
                for (int i = 0; i < listDate.Count; i++)
                {
                    string nameWorkSheet = ((listDate[i].Month) + "." + (listDate[i].Year)).ToString();

                    /* if (i == 0)
                     * {
                     *   sheet.Name = nameWorkSheet;
                     * }*/
                    //else
                    //{
                    reoGridControl.AddWorksheet(reoGridControl.CreateWorksheet(nameWorkSheet));

                    //}
                }
            }
            else
            {
                int           countOfWorkSheed = reoGridControl.Worksheets.Count;
                List <string> sheetsNames      = new List <string>();
                sheetsNames.Clear();
                for (int i = 0; i < countOfWorkSheed; i++)
                {
                    sheetsNames.Add(reoGridControl.Worksheets[i].Name);
                }
                for (int i = 0; i < listDate.Count; i++)
                {
                    string nameWorkSheet = ((listDate[i].Month) + "." + (listDate[i].Year)).ToString();
                    if (!sheetsNames.Contains(nameWorkSheet))
                    {
                        reoGridControl.AddWorksheet(reoGridControl.CreateWorksheet(nameWorkSheet));
                    }
                }
            }
        }