Exemplo n.º 1
0
        static void Main(string[] args)
        {
            //Array array= Enum.GetValues(typeof(ESex));

            //Console.WriteLine(System.Enum.GetName(typeof(ESex), 1));
            //Console.WriteLine(System.Enum.GetName(typeof(ESex), 2));
            //Console.WriteLine( Enum.Format(typeof(ESex), Enum.Parse(typeof(ESex), "女"), "D"));
            //Console.WriteLine(Enum.Format(typeof(ESex), Enum.Parse(typeof(ESex), "女"), "D"));
            ExcelImportHelper excelImportHelper = new ExcelImportHelper();

            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start(); //  开始监视代码运行时间

            List<SysUser> sysUserList = excelImportHelper.DataTableToList<SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");
            stopwatch.Stop(); //  停止监视
            TimeSpan timespan = stopwatch.Elapsed; //  获取当前实例测量得出的总时间
            System.Console.WriteLine($"第一次转换 {timespan.TotalSeconds}");
            System.Console.WriteLine($"第一次读取execl {sysUserList.Count}");
            string json = JsonConvert.SerializeObject(sysUserList);
            Console.WriteLine(json);
            stopwatch.Reset();

            stopwatch.Start(); //  开始监视代码运行时间

            sysUserList = excelImportHelper.DataTableToList<SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");
            stopwatch.Stop(); //  停止监视
            timespan = stopwatch.Elapsed; //  获取当前实例测量得出的总时间
            System.Console.WriteLine($"第二次转换 {timespan.TotalSeconds}");
            System.Console.WriteLine($"第二次读取execl {sysUserList.Count}");

            json = JsonConvert.SerializeObject(sysUserList);
            Console.WriteLine(json);
            System.Console.Read();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            //1.获取模块的完整路径。
            //string path1 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;

            //2.获取和设置当前目录(该进程从中启动的目录)的完全限定目录
            string path2 = System.Environment.CurrentDirectory;

            ////3.获取应用程序的当前工作目录
            //string path3 = System.IO.Directory.GetCurrentDirectory();

            ////4.获取程序的基目录
            //string path4 = System.AppDomain.CurrentDomain.BaseDirectory;

            ////5.获取和设置包括该应用程序的目录的名称
            //string path5 = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;

            Directory.SetCurrentDirectory(Directory.GetParent(path2).FullName);
            string path = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(Directory.GetParent(path).FullName);

            path = Directory.GetCurrentDirectory();
            string newPath = Path.Combine(path, "execl测试.xlsx");
            //Array array= Enum.GetValues(typeof(ESex));


            //Console.WriteLine(System.Enum.GetName(typeof(ESex), 1));
            //Console.WriteLine(System.Enum.GetName(typeof(ESex), 2));
            //Console.WriteLine( Enum.Format(typeof(ESex), Enum.Parse(typeof(ESex), "女"), "D"));
            //Console.WriteLine(Enum.Format(typeof(ESex), Enum.Parse(typeof(ESex), "女"), "D"));
            ExcelImportHelper excelImportHelper = new ExcelImportHelper();

            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start(); //  开始监视代码运行时间

            List <SysUser> sysUserList = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");

            stopwatch.Stop();                      //  停止监视
            TimeSpan timespan = stopwatch.Elapsed; //  获取当前实例测量得出的总时间

            System.Console.WriteLine($"第一次转换 {timespan.TotalSeconds}");
            System.Console.WriteLine($"第一次读取execl {sysUserList.Count}");
            string json = JsonConvert.SerializeObject(sysUserList);

            Console.WriteLine(json);
            stopwatch.Reset();

            stopwatch.Start(); //  开始监视代码运行时间

            sysUserList = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");
            stopwatch.Stop();             //  停止监视
            timespan = stopwatch.Elapsed; //  获取当前实例测量得出的总时间
            System.Console.WriteLine($"第二次转换 {timespan.TotalSeconds}");
            System.Console.WriteLine($"第二次读取execl {sysUserList.Count}");

            json = JsonConvert.SerializeObject(sysUserList);
            Console.WriteLine(json);
            System.Console.Read();
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            ExcelImportHelper excelImportHelper = new ExcelImportHelper();
            List <SysUser>    sysUserList       = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");

            System.Console.WriteLine($"读取execl {sysUserList.Count}");
            System.Console.Read();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            ExcelImportHelper excelImportHelper = new ExcelImportHelper();
            List <SysUser>    sysUserList       = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");

            System.Console.WriteLine($"读取execl {sysUserList.Count}");

            string json = JsonConvert.SerializeObject(account); Console.WriteLine(json);

            System.Console.Read();
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Console.WriteLine(Enum.ToObject(typeof(ESex), Enum.Parse(typeof(ESex), "男")));
            Console.WriteLine(Enum.ToObject(typeof(ESex), Enum.Parse(typeof(ESex), "女")));

            ExcelImportHelper excelImportHelper = new ExcelImportHelper();
            List <SysUser>    sysUserList       = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");

            System.Console.WriteLine($"读取execl {sysUserList.Count}");

            string json = JsonConvert.SerializeObject(sysUserList);

            Console.WriteLine(json);
            System.Console.Read();
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            foreach (object o in Enum.GetValues(typeof(ESex)))
            {
                Console.WriteLine("{0}:{1}", o, Enum.Format(typeof(ESex), o, "D"));
            }

            ExcelImportHelper excelImportHelper = new ExcelImportHelper();
            List <SysUser>    sysUserList       = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");

            System.Console.WriteLine($"读取execl {sysUserList.Count}");

            string json = JsonConvert.SerializeObject(sysUserList);

            Console.WriteLine(json);
            System.Console.Read();
        }
Exemplo n.º 7
0
        static void Main(string[] args)
        {
            //Array array= Enum.GetValues(typeof(ESex));


            //Console.WriteLine(System.Enum.GetName(typeof(ESex), 1));
            //Console.WriteLine(System.Enum.GetName(typeof(ESex), 2));
            //Console.WriteLine( Enum.Format(typeof(ESex), Enum.Parse(typeof(ESex), "女"), "D"));
            //Console.WriteLine(Enum.Format(typeof(ESex), Enum.Parse(typeof(ESex), "女"), "D"));
            ExcelImportHelper excelImportHelper = new ExcelImportHelper();

            System.Diagnostics.Stopwatch stopwatch = new Stopwatch();
            List <SysUser> sysUserList             = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");

            System.Console.WriteLine($"读取execl {sysUserList.Count}");

            string json = JsonConvert.SerializeObject(sysUserList);

            Console.WriteLine(json);
            System.Console.Read();
        }
Exemplo n.º 8
0
 static void Main(string[] args)
 {
     ExcelImportHelper excelImportHelper = new ExcelImportHelper();
     List <SysUser>    sysUserList       = excelImportHelper.DataTableToList <SysUser>(@"C:\Users\chenke\Desktop\execl测试.xlsx");
 }