还要什么demo,反正代码页很少,我在这发吧。
页面上就3个文本框,一个按钮,一个FpSpread,没别的控件。后台代码如下:
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Data;
- using System.Data.OleDb;
- using System.Configuration;
- namespace ysjyb
- {
- public partial class zdgz : System.Web.UI.Page
- {
- String ConnStr = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- TextBox_ny1.Text = “201303”;
- TextBox_ny2.Text = “201203”;
- TextBox_nlc.Text = "3";
- fp_bind();
-
- }
- }
- void fp_bind()
- {
- OleDbConnection conn = new OleDbConnection(ConnStr);
- conn.Open();
- OleDbCommand cmd = conn.CreateCommand();
- cmd.CommandText = "select c.km,c.dm,a.* from (select a.jh,a.rynl nl1,b.rynl nl2,a.rynl-b.rynl nlc from (select * from yd_bb_yjdjsjb where ny='"+TextBox_ny2.Text+"') a,(select * from yd_bb_yjdjsjb where ny='"+TextBox_ny1.Text+"') b where a.jh=b.jh) a,ys_daa01 b,dwdzb c where a.jh=b.jh and b.dwdm=c.dwdm and nlc>"+TextBox_nlc.Text+" order by c.km,c.dm,nlc desc";
- OleDbDataAdapter da = new OleDbDataAdapter();
- Response.Write(cmd.CommandText);
- da.SelectCommand = cmd;
- DataSet ds = new DataSet();
- da.Fill(ds);
- FpSpread1.ActiveSheetView.DataSource = ds;
- ds.Dispose();
- da.Dispose();
- cmd.Dispose();
- conn.Close();
- conn.Dispose();
- FarPoint.Web.Spread.Model.GroupDataModel gdm = new FarPoint.Web.Spread.Model.GroupDataModel(FpSpread1.ActiveSheetView.DataModel);
- FarPoint.Web.Spread.SortInfo[] st = new FarPoint.Web.Spread.SortInfo[2];
- st[0] = new FarPoint.Web.Spread.SortInfo(0, true);
- st[1] = new FarPoint.Web.Spread.SortInfo(1, true);
- gdm.Group(st);
- FpSpread1.ActiveSheetView.DataModel = gdm;
- FpSpread1.ActiveSheetView.GroupFooterVisible = true;
- FpSpread1.ActiveSheetView.ColumnFooter.RowCount = 1;
- FpSpread1.ActiveSheetView.Columns[3].AggregationType = FarPoint.Web.Spread.Model.AggregationType.Sum;
- FpSpread1.ActiveSheetView.Columns[4].AggregationType = FarPoint.Web.Spread.Model.AggregationType.Sum;
- FpSpread1.ActiveSheetView.Columns[5].AggregationType = FarPoint.Web.Spread.Model.AggregationType.Sum;
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- fp_bind();
- }
- }
- }
复制代码 |