private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { List <People> list = new List <People>(); list.Add(new People() { Name = "张三", Age = "10" }); list.Add(new People() { Name = "李四", Age = "11" }); list.Add(new People() { Name = "王五", Age = "13" }); list.Add(new People() { Name = "345张三", Age = "17" }); Hashtable ht = new Hashtable(); ht.Add("Name", "姓名"); ht.Add("Age", "年龄"); string path = "D:\\21.xls"; ExcelManager <People> .getExcel(list, ht, path); }
private void Button_Click(object sender, RoutedEventArgs e) { ExcelManager.test3(); // HSSFWorkbook workbook = new HSSFWorkbook(); //ISheet sheet = workbook.CreateSheet("sheet1"); //ExcelManager.SetCellDropdownList(sheet, 1, 1, new List<string>() { "男", "女", "保密" }.ToArray()); //MemoryStream ms=new MemoryStream(); //workbook.Write(ms); //ms.Flush(); //ms.Position = 0; //sheet = null; //string workbookFile = @"D:\\wulei.xls"; //workbook = null; //FileStream fs = new FileStream(workbookFile, FileMode.Create, FileAccess.Write); //byte[] data = ms.ToArray(); //fs.Write(data, 0, data.Length); //fs.Flush(); //fs.Close(); }