ASP.NET中如何灵活的操作一个复杂的Excel表,例如读取指定的 单元格C3的内容 或者 C3:F3的内容其实我主要就是想判断 一下C1单元格是否是 是"SUM(A1:B1)" 大虾们能详细点么?我很新手的~~分也不多求教~我有用如下代码把excel中的题目表导入DataGrid中,但是没用....求指教、求教育:    protected void Page_Load(object sender, EventArgs e)
    {
        DataSet ds=ExcelToDS(@"C:\Users\Administrator\Desktop\excel.xls");
        DataGrid1.DataSource = ds.Tables["table"].DefaultView;
        DataGrid1.DataBind();
    }    /// <summary>
    /// 读取Excel文档
    /// </summary>
    /// <param name="Path">文件名称</param>
    /// <returns>返回一个数据集</returns>
    public DataSet ExcelToDS(string Path)
    {
        string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
        OleDbConnection conn = new OleDbConnection(strConn);
        conn.Open();
        string strExcel = "";
        OleDbDataAdapter myCommand = null;
        DataSet ds = null;
        strExcel = "select * from [题目$]";
        myCommand = new OleDbDataAdapter(strExcel, strConn);
        ds = new DataSet();
        myCommand.Fill(ds, "table");
        return ds;
    }

解决方案 »

  1.   

    额 在单元格中取值也做到了~代码:
        ///<summary>
        ///读取单元格
        ///</summary>
        private void a()
        {
            Excel.Application ObjApp=new Excel.ApplicationClass();//创建一个Excel对象   
            Excel.Sheets ObjSheets;//定义一个工作表组   
            Excel._Worksheet ObjSheet;//定义一个工作表          ObjApp.Workbooks.Open(Server.MapPath(@".\excel.xls"), System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing, System.Type.Missing);
            ObjSheets = ObjApp.Worksheets;//引用工作簿中的工作表   
            ObjSheet = (Excel._Worksheet)ObjSheets.get_Item(1);//得到工作表组中第一个工作表   
            Excel.Range rang = (Excel.Range)ObjSheet.Cells[3, 1];
            Response.Write(rang.Text);  
        }求教:怎么去判断单元格是否使用函数呢?使用什么函数呢?
      

  2.   

    参见
    使用 ADO.NET 更新 Excel 中指定单元格的内容 String sql = "Select * from [Sheet1$C3:C3]";