//按钮事件
protected void btnQueryExcel_Click(object sender, EventArgs e)
{
DataSet ds; string strError;
string SaveFilePath = Server.MapPath(Page.Request.ApplicationPath) + "//UpLoadExcel";
if (!System.IO.Directory.Exists(SaveFilePath))
System.IO.Directory.CreateDirectory(SaveFilePath);
if (FileUpload1.FileName.Trim() =="")
{
alert("请选择要导入的Excel");
return;
}
FileUpload1.SaveAs(SaveFilePath + "//" + FileUpload1.FileName);
string Sql = "SELECT * FROM [CCS$];";
bool bRet = ImportDataFromExcelToDs(out ds, SaveFilePath + "//" + FileUpload1.FileName, Sql, out strError);
if (!bRet)
{
alert(strError);
return;
}
if (ds.Tables.Count == 0 && ds.Tables[0].Rows.Count > 0)
{
alert("没有数据");
return;
}
if (!QueryExcelData(ds, out strError))
{
alert(strError);