回复 1楼zenki123的帖子
请使用以下代码更换特定列头单元格背景色:
- protected void Page_Load(object sender, EventArgs e)
- {
- if (IsPostBack)
- {
- return;
- }
- FpSpread1.ActiveSheetView.ColumnHeader.RowCount = 2;
- FpSpread1.ActiveSheetView.Columns.Count = 4;
- FpSpread1.ActiveSheetView.ColumnHeaderSpanModel.Add(0, 0, 2, 1);
- FpSpread1.ActiveSheetView.ColumnHeaderSpanModel.Add(0, 1, 1, 3);
- FpSpread1.ActiveSheetView.ColumnHeader.Cells[0, 0].Text = "A";
- FpSpread1.ActiveSheetView.ColumnHeader.Cells[0, 1].Text = "B";
- FpSpread1.ActiveSheetView.ColumnHeader.Cells[1, 1].Text = "C";
- FpSpread1.ActiveSheetView.ColumnHeader.Cells[1, 2].Text = "D";
- FpSpread1.ActiveSheetView.ColumnHeader.Cells[1, 3].Text = "E";
- FarPoint.Web.Spread.NamedStyle si=new FarPoint.Web.Spread.NamedStyle();
- FarPoint.Web.Spread.Background bg = new FarPoint.Web.Spread.Background();
- si.Name="colheaderstyle";
- si.Background=bg;
- bg.BackgroundImageUrl =Server.MapPath("test.png");
-
- this.FpSpread1.ActiveSheetView.NamedStyles.Add(si);
- this.FpSpread1.Sheets[0].ColumnHeader.Cells[0,0].StyleName="colheaderstyle";
- }
复制代码 |