private void exportExcel_Click(object sender, EventArgs e) { String filePath = new Maticsoft.Common.INIFile().IniReadValue("config", "downloadPath");; String fileName = "member.xls"; String[] title = new String[] { "会员卡号", "卡面号", "会员姓名" ,"手机号码","邮件","性别","当前等级", "当前积分", "当前余额", "累计消费", "会员卡状态" }; int[] width = new int[] { 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20 }; VipSoft.BLL.MemCard memCard = new BLL.MemCard(); DataSet ds = memCard.GetExportList(condition); VipSoft.Common.NPOI2.ExcelInfo ei = new VipSoft.Common.NPOI2.ExcelInfo(); ei.filePath = filePath + fileName; VipSoft.Common.NPOI2.ExcelUtils.writeExcel(ds.Tables[0], ei, title, width); SaveFileDialog SaveFile = new SaveFileDialog(); SaveFile.FileName = fileName; SaveFile.Filter = "Miscrosoft Office Excel 97-2003 工作表|*.xls|所有文件(*.*)|*.*"; SaveFile.RestoreDirectory = true; if (SaveFile.ShowDialog() == DialogResult.OK) { String destFName = SaveFile.FileName; System.IO.File.Copy(filePath+fileName, destFName, true);//文件另存为 MessageBox.Show("文件导出成功"); } }