private void button2_Click(object sender, EventArgs e) { string strsql = "select top 100 WaterMeterAddress,RechargeCount,CreateUserName,CreateTime from [dbo].[MeiShan_Install_WaterUserMeter]"; var data = GetDataTable(strsql); string path = @"D:\" + "欠费" + DateTime.Now.ToString("yyyy-MM-dd HHmmss") + ".xlsx"; ExcelHelp.TableToExcelForXLSX(data, path); }