onclick ="return bnQuery_onclick()" onserverclick ="bnQuery_ServerClick"
public void createexcel(dataset ds,string typeid,string filename) { httpresponse resp; resp = page.response; resp.contentencoding = system.text.encoding.getencoding("gb2312"); resp.appendheader("content-disposition", "attachment;filename=" + filename); string colheaders= "", ls_item=""; int i=0; //定义表对象与行对像,同时用dataset对其值进行初始化 datatable dt=ds.tables; datarow.caption.tostring()+"/t"; colheaders +=dt.columns.caption.tostring() +"/n"; //向http输出流中写入取得的数据信息 resp.write(colheaders); //逐行处理数据 foreach(datarow row in myrow) { //在当前行中,逐列获得数据,数据之间以/t分割,结束时加回车符/n for(i=0;i ls_item +=row.tostring() + "/t"; ls_item += row.tostring() +"/n"; //当前行数据写入http输出流,并且置空ls_item以便下行数据 resp.write(ls_item); ls_item=""; } } else { if(typeid=="2") { //从dataset中直接导出xml数据并且写到http输出流中 resp.write(ds.getxml()); } } //写缓冲区中的数据到http头文件中 resp.end(); }