private void button1_Click(object sender, EventArgs e) { SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "*.xls|*xls"; if (saveFile.ShowDialog() != DialogResult.OK) { return; } string fileName = saveFile.FileName; ExcelOperate ExportExcel = new ExcelOperate(); if (ExportExcel.DataSetToExcel(dgvAllData, fileName, false)) { MessageBox.Show("导出成功", "提示"); } }
/// <summary> /// 将下载类别导出成Excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExportDataList_Click(object sender, EventArgs e) { if (m_mainWeb.m_DownLoadList.Count > 0) { MessageBox.Show("当前还有数据未下载,请全部下载完成后再进行导出!", "提示"); return; } SaveFileDialog saveFile = new SaveFileDialog(); saveFile.Filter = "*.xls|*xls"; if (saveFile.ShowDialog() != DialogResult.OK) { return; } string fileName = saveFile.FileName; ExcelOperate ExportExcel = new ExcelOperate(); if (ExportExcel.DataSetToExcel(dgvAllData, fileName, false)) { MessageBox.Show("导出成功", "提示"); } }