Excel.Application m_objExcel = new Application();
            m_objExcel.Application.Workbooks.Add(true);
            for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
            {
                m_objExcel.Cells[1, j + 1] = ds.Tables[0].Columns[j].ColumnName;
            }
            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
                {
                    m_objExcel.Cells[i+2, j+1] = ds.Tables[0].Rows[i][j].ToString();
                }
            }
            m_objExcel.Visible = false;操作完成以后怎么才能弹出那个 “保存 打开 取消”的对话框?
请各位高手指点下。

解决方案 »

  1.   

    Save Excel File, and get the path of the file
    objBook.SaveAs(FileName:=TempFile, FileFormat:=Excel.XlFileFormat.xlExcel9795)
    Open it
    Response.Write("<script language='javascript'>window.open('" & objReport & "')</script>")
      

  2.   

    objReport is the path of the file ^_^!
      

  3.   

    m_objExcel.DisplayAlerts = false;
      

  4.   

    不好意思m_objExcel.DisplayAlerts   =   true;
      

  5.   

    @jetxia  
    我试过这种方式,不行啊
      

  6.   

    把文件先保存在服务器的一个临时文件夹下,然后用System.IO.FileInfo把文件再读回来
    最后用Response.WriteFile写到客户端,然后删除临时文件,就好了