/// <summary>
/// 导出表格数据到文件
/// </summary>
/// <param name="gridView"></param>
/// <param name="strCaption"></param>
public static void ExportFile(GridView gridView, string strCaption)
{
SaveFileDialog sf = new SaveFileDialog();
sf.FileName = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
sf.AddExtension = true;//自动添加扩展名
switch (strCaption)
{
case "Excel文件":
sf.DefaultExt = "xlsx";
sf.Filter = "Excel文件 (*.xlsx)|*.xlsx|Excel文件(*.xls)|*.xls";
if (sf.ShowDialog() == DialogResult.OK)
{
if (sf.FileName.EndsWith("xlsx"))
gridView.ExportToXlsx(sf.FileName);