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); }
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", "信息一览"); }