回复 5楼guxinghan的帖子
Spread 在后台可以复制数据、公式和样式,分别使用不同的模型来实现,其中公式和数据都使用DefaultSheetDataModel 来实现:
请你尝试以下代码:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- FpSpread1.ActiveSheetView.RowCount = 10;
- for (int i = 0; i < 1; i++)
- {
- FpSpread1.ActiveSheetView.SetValue(i, 0, i);
- FpSpread1.ActiveSheetView.SetValue(i, 1, i);
- FpSpread1.ActiveSheetView.SetValue(i, 2, i);
- }
- this.FpSpread1.ActiveSheetView.SetFormula(0, 3, "SUM(A1:C1)");
- FarPoint.Web.Spread.Model.DefaultSheetStyleModel model = (FarPoint.Web.Spread.Model.DefaultSheetStyleModel)FpSpread1.Sheets[0].StyleModel;
- FarPoint.Web.Spread.StyleInfo style = new FarPoint.Web.Spread.StyleInfo();
- style.BackColor = Color.Yellow;
- model.SetDirectInfo(0, 0, style);
- }
- //复制数据
- protected void Button2_Click(object sender, EventArgs e)
- {
- FarPoint.Web.Spread.Model.DefaultSheetDataModel dm = (FarPoint.Web.Spread.Model.DefaultSheetDataModel)FpSpread1.ActiveSheetView.DataModel;
- dm.Copy(0, 0, 1, 0, 1, 4);
- }
- //复制样式
- protected void Button1_Click(object sender, EventArgs e)
- {
- FarPoint.Web.Spread.Model.DefaultSheetStyleModel model = (FarPoint.Web.Spread.Model.DefaultSheetStyleModel)FpSpread1.Sheets[0].StyleModel;
- model.Copy(0, 0, 1, 0, 1, 4);
- }
复制代码 |