回复 7楼wotangjing的帖子
结合上面的demo,添加新增行按钮函数,参考代码如下:
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- //新增一行
- MyWorksheet sheet = this.gcSpreadSheet1.ActiveSheet as MyWorksheet;
- sheet.RowCount++;
- //值拷贝
- ValueCopy(sheet.RowCount - 2, sheet.RowCount - 1);
-
- }
- private void ValueCopy(int from_row, int to_row)
- {
- MyWorksheet sheet = this.gcSpreadSheet1.ActiveSheet as MyWorksheet;
- int colCount = sheet.ColumnCount;
- for (int i = 0; i < colCount; i++)
- {
- object oldValue = sheet.Rows[from_row].GetValue(i);
- sheet.Rows[to_row].SetValue(i, oldValue);
- }
-
- }
复制代码 |