Spread Studio for .NET 7: 使用现有数据填充单元格
程序员文章站
2022-03-18 23:48:29
...
使用 Spread Studio 表格控件你可以复制范围单元格并且填充到其他单元格中,复制数据和单元格格式。例如:如果目前有 2*2 个单元格,你可以在任意方向实现任意次数填充单元格到表单中。
我们通过 FillRange 方法来实现此功能:
public void FillRange( int row, int column, int rowCount, int columnCount, int fillCount, FillDirection 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); }
效果图:
使用控件地址: 点击查看