我有,最近做了n表excel報表。你分都果給我呀
給我發信
[email protected]

解决方案 »

  1.   

    http://expert.csdn.net/Expert/topic/1454/1454452.xml?temp=.4400293
      

  2.   

    DataSet ds = new DataSet();
    string conn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\Book1.xls;Extended Properties=\"Excel 8.0;\"";
    OleDbConnection myConnection = new OleDbConnection(conn);
    string sql = "select * from [Sheet1$]";
    OleDbCommand myCommand = new OleDbCommand(sql,myConnection);
    OleDbDataAdapter da = new OleDbDataAdapter(myCommand);
    da.Fill(ds);
    ListDataGrid.DataSource = ds;
    ListDataGrid.DataBind();
    我用上面的方法打开了一个excel
    问:可以直接打开服务器端的吗?
    问:怎么在datagrid上修改后改变原来的文件
    问:怎么把改过的文件也保存到服务端?
      

  3.   

    公司改变了做法,问:我怎么把数据库的数据,表现在excel上
      

  4.   

    <%@ Language=VBScript %>
    <%
    Response.Buffer = True
    Response.ContentType = "application/vnd.ms-excel"
    %>
    <table border="2" cellpadding="20">
       <tr>
          <th>项目 A</th>
          <th>项目 B</th>
          <th>总计</th>
       </tr>
       <tr>
          <td>4</td>
          <td>3</td>
          <td><font color="red">=sum(a2:b2)</font></td>
       </tr>
       <tr>
          <td>2</td>
          <td>1</td>
          <td><font color="red">=sum(a3:b3)</font></td>
       </tr>
    </table>
      

  5.   

    给你一个方法。
    /// <summary>
    /// <author>bruce.pu</author>
    /// 要使用此方法,请先加入microsoft Office Web Component。
    /// 具体实现可以参照例子wms/vas
    /// </summary>
    /// <param name="mdv">主表数据</param>
    /// <param name="mstTableHead">主表头</param>
    /// <param name="mstCol">主表列名</param>
    /// <param name="dt">子表数据</param>
    /// <param name="tableHead">子表头</param>
    /// <param name="col">子表列</param>
    /// <param name="pathAndFileName">文件路径名,例如"d:\\test"请注意格式</param>
    ///  <returns></returns>
    public static string WriteDataGrid2Excel(DataView mdv,ArrayList mstTableHead,ArrayList mstCol,DataView dt,ArrayList tableHead,ArrayList col,string pathAndFileName) 
    {
    try
    {
    SpreadsheetClass xlsheet = new SpreadsheetClass();
    int mstrowCount=0;
    /////////////主表信息
    if(mdv.Table.Rows.Count!=0)
    {
    for(int msthead=0;msthead<mstTableHead.Count;msthead++)
    {
    xlsheet.ActiveSheet.Cells[1,msthead+1]=mstTableHead[msthead];
    // xlsheet.ActiveSheet.Cells[ 1,msthead+1].Color   =  "#ff0011";
    }
    mstrowCount+=1;
    for(int mstContent=0;mstContent<(mdv.Table.Rows.Count);mstContent++)
    {
    DataRow mrw = mdv.Table.Rows[mstContent];
    for(int mstCellCount=0;mstCellCount<mstCol.Count;mstCellCount++)
    {
    string mstCellContent=mrw[mstCol[mstCellCount].ToString()].ToString();
    if(mstCellContent=="&nbsp;")
    xlsheet.ActiveSheet.Cells[mstContent+mstrowCount+1,mstCellCount+1]="";
    else
    xlsheet.ActiveSheet.Cells[mstContent+mstrowCount+1,mstCellCount+1]=mstCellContent;
    }
    }
    mstrowCount+=mdv.Table.Rows.Count;
    }
    //////////////子表信息
    int i;
    for (int j=0;j<tableHead.Count;j++) 
    {
    xlsheet.ActiveSheet.Cells[mstrowCount+1,j+1]=tableHead[j];
    }
    for(i=0;i<dt.Table.Rows.Count;i++)//行

    DataRow rw = dt.Table.Rows[i];
    for (int j=0;j<col.Count;j++) //列
    {
    string cell=rw[col[j].ToString()].ToString();
    if(cell=="&nbsp;")
    xlsheet.ActiveSheet.Cells[mstrowCount+i+2,j+1] = "";
    else xlsheet.ActiveSheet.Cells[mstrowCount+i+2,j+1] =cell;
    }

    xlsheet.ActiveSheet.Export(pathAndFileName,OWC.SheetExportActionEnum.ssExportActionNone);
    return "true";
    }
    catch(Exception ee)
    {
    return ee.Message.ToString();
    }
    }
      

  6.   

    http://www.csdn.net/Develop/read_article.asp?id=15544
    http://www.csdn.net/Subject/15/index.shtm
    http://www.linkmeng.com/article/listart.asp?artid=100
      

  7.   

    it's to hard to "保存到服务器数据库" , 除非自己写 VBA or Excel Application.