因为你需要设置的是动态的不确定区域,所以并没有十分便捷的方法
如果复制行中每个单元格的格式固定的,可以创建NamedStyle来存放这些样式,然后将这些样式应用到需要的单元格中:
- FarPoint.Win.Spread.NamedStyle ns1 = new FarPoint.Win.Spread.NamedStyle("TestStyle1");
- FarPoint.Win.Spread.NamedStyle ns2 = new FarPoint.Win.Spread.NamedStyle("TestStyle2");
- private void Form1_Load(object sender, EventArgs e)
- {
- ns1.BackColor = Color.LightPink;
- ns1.Border = new FarPoint.Win.LineBorder(Color.BlueViolet, 2);
- ns2.BackColor = Color.Black;
- ns2.Border = new FarPoint.Win.LineBorder(Color.Red, 1);
- fpSpread1.NamedStyles.Add(ns1);
- fpSpread1.NamedStyles.Add(ns2);
- }
- private void Button1_Click(object sender, EventArgs e)
- {
- fpSpread1.ActiveSheet.Cells[0, 0, 1, 2].StyleName = "TestStyle1";
- fpSpread1.ActiveSheet.Cells[2, 3, 4, 5].StyleName = "TestStyle2";
- }
复制代码 |