public void ToExecelTest()
        {
            string _excelpath = string.Format(@"D:\ToExecelTest_{0}.xls", DateTime.Now.FormatDate(12));

            if (File.Exists(_excelpath))
            {
                File.Delete(_excelpath);
            }

            MyxlsExcel.ToExecel <Person>(personList, _excelpath, "PersonInfo");
            bool _actual = File.Exists(_excelpath);

            Assert.IsTrue(_actual);
        }
Пример #2
0
        private void button11_Click(object sender, EventArgs e)
        {
            DataTable _table = new DataTable();

            _table.Columns.Add(new DataColumn("名称", typeof(string)));
            _table.Columns.Add(new DataColumn("年龄", typeof(int)));
            _table.Columns.Add(new DataColumn("出生", typeof(DateTime)));

            for (int i = 0; i < 10; i++)
            {
                DataRow _row = _table.NewRow();
                _row["名称"] = "churenyouzi" + i;
                _row["年龄"] = i;
                _row["出生"] = DateTime.Now.AddYears(-20);
                _table.Rows.Add(_row);
            }

            MyxlsExcel.ToExecel(_table, @"D:\myxlsTest.xls", "信息一览");
        }
Пример #3
0
        public void ToDataTableTest()
        {
            DataTable _actual = MyxlsExcel.ToDataTable(@"D:\为制作DB而临时产生的文件_愚园路246弄.xls", 0);

            Assert.IsNotNull(_actual);
        }