使用 Spread Studio 表格控件你能够复制范围单元格而且填充到其余单元格中,复制数据和单元格格式。例如:若是目前有 2*2 个单元格,你能够在任意方向实现任意次数填充单元格到表单中。 html
咱们经过 FillRange 方法来实现此功能: post
public void FillRange( int row, int column, int rowCount, int columnCount, int fillCount, FillDirection fillDirection )参数 row开始复制单元格范围的行索引 column开始复制单元格范围的列索引 rowCount复制单元格范围的行数 columnCount复制单元格范围的行数 fillCount填充次数 fillDirection填充方向
测试代码: 测试
private void Form1_Load(object sender, EventArgs e) { // Define the text to repeat. fpSpread1.ActiveSheet.Cells[0, 0].Text = "A1-text"; fpSpread1.ActiveSheet.Cells[0, 1].Text = "A2-text"; fpSpread1.ActiveSheet.Cells[1, 0].Text = "B1-text"; fpSpread1.ActiveSheet.Cells[1, 1].Text = "B2-text"; fpSpread1.ActiveSheet.Cells[0, 0].BackColor = Color.Cyan; fpSpread1.ActiveSheet.Cells[0, 0].ForeColor = Color.DarkBlue; fpSpread1.ActiveSheet.Cells[0, 1].BackColor = Color.Coral; fpSpread1.ActiveSheet.Cells[0, 1].ForeColor = Color.DarkRed; } private void 横向填充ToolStripMenuItem_Click(object sender, EventArgs e) { //向右填充 fpSpread1.ActiveSheet.FillRange(0, 1, 2, 1, 3, FillDirection.Right); } private void 向下填充ToolStripMenuItem_Click(object sender, EventArgs e) { //向下填充 fpSpread1.ActiveSheet.FillRange(0, 0, 2, 2, 4, FillDirection.Down); }
效果图:
使用控件地址: 点击查看