从 一个类表中吧数据导出到 EXCEL 中 到处之后 在执行一个 DELETE() 方法
protected void btnToExel_Click( object sender, EventArgs e )
{
DataSet ds = new DataSet(); ds = GetDataSet(); if ( ds.Tables[ 0 ].Rows.Count > 0 ) {
this.grdMedicine.DataSource = this.GetDataSet().Tables[ 0 ].DefaultView; this.grdMedicine.DataBind();
}
GridViewExportUtil.Export( this.grdMedicine,"phk.xls" );//导出方法
DELETE(); }
我想要的结果是导出成功之后才执行DELETE()方法 但是我不知道怎么样才能判断有没有导出成功,请各位大虾指教下,有点急 ,谢谢了
protected void btnToExel_Click( object sender, EventArgs e )
{
DataSet ds = new DataSet(); ds = GetDataSet(); if ( ds.Tables[ 0 ].Rows.Count > 0 ) {
this.grdMedicine.DataSource = this.GetDataSet().Tables[ 0 ].DefaultView; this.grdMedicine.DataBind();
}
GridViewExportUtil.Export( this.grdMedicine,"phk.xls" );//导出方法
DELETE(); }
我想要的结果是导出成功之后才执行DELETE()方法 但是我不知道怎么样才能判断有没有导出成功,请各位大虾指教下,有点急 ,谢谢了
DELETE();
Response.Write("Result");或者在DELETE();中alert一下
成功就可以执行你delete()
{
DataSet ds = new DataSet(); ds = GetDataSet(); if ( ds.Tables[ 0 ].Rows.Count > 0 ) {
this.grdMedicine.DataSource = this.GetDataSet().Tables[ 0 ].DefaultView; this.grdMedicine.DataBind();
}
GridViewExportUtil.Export( this.grdMedicine,"phk.xls" );//导出方法
//判断一下文件是否存在
if(File.Exists("phk.xls")) //文件存在
{
DELETE();
}
}
HttpResponse hr = Page.Response;
hr.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
hr.AddHeader("Content-Disposition", string.Format("attachment;filename={0}.csv", HttpUtility.UrlEncode(DateTime.Now.ToShortDateString());
string ls_item = "";
//获取标题
string header = "表头,表头,表头,表头,表头\n";
hr.Write(header); hr.Write("表头,表头,表头,表头,表头");//这里的内容,可循环你的DataSet来实现,加上\n表示换行
hr.End();
if(File.Exists("phk.xls")) //文件存在
{
DELETE();
}
这个能判断吗?导出的时候又没有具体路径的,路径是导出的时候自己选择的,我怎么判断
之后看那个函数运行不运行。导出没导出成功 检查那个路径下是否有这个文件不就行了。