导出EXCEL的C#代码有谁知道及生成安装程序的配置.

解决方案 »

  1.   

    SaveAs( 'C:\Excel\Demo1.xls' );
      

  2.   

    你把需要导入的内容转换成二维数组,然后用循环写入excel就可以了!
      

  3.   

    protected System.Web.UI.WebControls.DataGrid dg1;
    public struct strcell
    {
    public int irow;
    public string strcol;
    }
    private void Page_Load(object sender, System.EventArgs e)
    {
    try
    {
    string connstr="Provider=OraOLEDB.Oracle.1;User ID=;DataSource=;password=";
    OleDbConnection Conn= new OleDbConnection(connstr) ; 
    Conn.Open();
    string mysql="select * from english_1";
    OleDbCommand Comm=new OleDbCommand (mysql,Conn);
    OleDbDataAdapter da=new OleDbDataAdapter();
    da.SelectCommand =Comm;
    DataSet ds=new DataSet ();
    da.Fill (ds,"table_1");
    DataView s=new DataView (ds.Tables["table_1"]);
    dg1.DataSource = s;
    dg1.DataBind();
                    
                 strcell  xx1=this.SplitExcelCell("AF16");
    Conn.Close ();
    }
    catch(Exception ex)
    {
    Response.Write("连接失败");

    }
    }
          //  定义另一个函数splitExcelCell取值函数作用是返回单元格坐标的“字母和数字”
    private strcell SplitExcelCell(string strcellcount)//定义一个单元格坐标变量如 {
    char[] chnum=new char[]{'0', '1',  '2','3','4','5','6','7','8', '9'};
    strcell x1;//重载X1
    int pos=strcellcount.IndexOfAny(chnum);//单元格坐标变量中第一个数字的位置
     x1.irow=int.Parse(strcellcount.Substring(pos,strcellcount.Length-pos));//将第pos个字符开始的单元格坐标字符串转换成整型,
    x1.strcol=strcellcount.Substring(0,pos);//截取前面的字符串的字符
    return x1;//返回strcell结构体(返回的为两个值)
         }

    }
    }
      

  4.   

    我有ASP.NET的程序,LZ你要吗?
    差不多的。
      

  5.   

    看一下我刚回答的问题http://community.csdn.net/Expert/topic/4744/4744903.xml?temp=.6966364