第二种方法的代码:
- private void Form1_Load(object sender, EventArgs e)
- {
- fpSpread1.Sheets[0].ColumnCount = 10;
- fpSpread1.Sheets[0].RowCount = 20;
- // 设置最后三列之间的边线不显示
- fpSpread1.Sheets[0].VerticalGridLine = new FarPoint.Win.Spread.GridLine(FarPoint.Win.Spread.GridLineType.None);
- FarPoint.Win.LineBorder border = new FarPoint.Win.LineBorder(Color.LightGray, 1, false, false, true, true);
- fpSpread1.Sheets[0].Columns[0, fpSpread1.Sheets[0].Columns.Count - 4].Border = border;
- fpSpread1.Sheets[0].Cells[0, 7].Text = "操作";
- fpSpread1.Sheets[0].Cells[0, 7].ColumnSpan = 3;
- fpSpread1.Sheets[0].Cells[0, 7].VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center;
- fpSpread1.Sheets[0].Columns[7, 9].HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center;
- fpSpread1.Sheets[0].Columns[7, 9].ForeColor = Color.FromArgb(180,0,0);
- for (int i = 1; i < fpSpread1.Sheets[0].Rows.Count; i++)
- {
- fpSpread1.Sheets[0].Cells[i, 7].Text = "修改";
- fpSpread1.Sheets[0].Cells[i, 8].Text = "删除";
- fpSpread1.Sheets[0].Cells[i, 9].Text = "查看";
- }
- }
复制代码 |