将格式页缓存起来。然后恢复就好了。
- object[,] cacheFillRangeData;
- GrapeCity.Windows.SpreadSheet.Data.StyleInfo[,] cacheFillRangeStyle;
- private void GcSpreadSheet1_DragFillBlock(object sender, GrapeCity.Windows.SpreadSheet.UI.DragFillBlockEventArgs e)
- {
- if (gcSpreadSheet1.ActiveSheet.RowFilter.IsFiltered)
- {
- cacheFillRangeData = gcSpreadSheet1.ActiveSheet.GetArray(e.FillRange.Row, e.FillRange.Column, e.FillRange.RowCount, e.FillRange.ColumnCount);
- cacheFillRangeStyle = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo[e.FillRange.Row, e.FillRange.ColumnCount];
- for (var i = 0; i < e.FillRange.RowCount; i++)
- {
- int row = e.FillRange.Row + i;
- if (gcSpreadSheet1.ActiveSheet.RowFilter.IsRowFilteredOut(row))
- {
- for (var j = 0; j < e.FillRange.ColumnCount; j++)
- {
- int col = e.FillRange.Column + j;
- cacheFillRangeStyle[i, j] = gcSpreadSheet1.ActiveSheet.GetStyleInfo(row, col, GrapeCity.Windows.SpreadSheet.Data.SheetArea.Cells);
- }
- }
- }
- }
- }
- private void GcSpreadSheet1_DragFillBlockCompleted(object sender, GrapeCity.Windows.SpreadSheet.UI.DragFillBlockCompletedEventArgs e)
- {
- if (gcSpreadSheet1.ActiveSheet.RowFilter.IsFiltered)
- {
- for (var i = 0; i < e.FillRange.RowCount; i++)
- {
- int row = e.FillRange.Row + i;
- if (gcSpreadSheet1.ActiveSheet.RowFilter.IsRowFilteredOut(row))
- {
- for (var j = 0; j < e.FillRange.ColumnCount; j++)
- {
- int col = e.FillRange.Column + j;
- gcSpreadSheet1.ActiveSheet.Cells[row, col].Value = cacheFillRangeData[i, j];
- gcSpreadSheet1.ActiveSheet.SetStyleInfo(row, col, cacheFillRangeStyle[i, j]);
- }
- }
- }
- cacheFillRangeData = null;
- cacheFillRangeStyle = null;
- }
- }
复制代码 |