http://dev.csdn.net/Develop/article/15/15544.shtm

解决方案 »

  1.   

    Excel.Application excel= new Excel.Application();
      int rowIndex=1;
      int colIndex=0;  excel.Application.Workbooks.Add(true);
        
      DataTable table=GetData();
         
      //将所得到的表的列名,赋值给单元格
      foreach(DataColumn col in table.Columns)
      {
       colIndex++; 
       excel.Cells[1,colIndex]=col.ColumnName;    
      }  //同样方法处理数据
      foreach(DataRow row in table.Rows)
     {
        rowIndex++;
        colIndex=0;
        foreach(DataColumn col in table.Columns)
        {
     colIndex++;
     excel.Cells[rowIndex,colIndex]=row[col.ColumnName].ToString();
        }
      }
      //不可见,即后台处理
      excel.Visible=true;