找回密码
 立即注册

QQ登录

只需一步,快速开始

pblandscape

初级会员

19

主题

46

帖子

397

积分

初级会员

积分
397

微信认证勋章

pblandscape
初级会员   /  发表于:2017-3-29 18:51  /   查看:3865  /  回复:5
本帖最后由 pblandscape 于 2017-3-29 18:55 编辑

参见附件,如何才能达到筛选后跨行拖拉的问题

筛选后跨行拖拉的问题.docx

37.85 KB, 下载次数: 213

筛选后跨行拖拉的问题

5 个回复

倒序浏览
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-3-30 09:37:26
沙发
Spread WPF没有提供这样的功能。一个解决方案是在填充前缓存数据,填充后判断如果是被过滤的行就恢复。

  1.         object[,] cacheFillRangeData;
  2.         private void GcSpreadSheet1_DragFillBlock(object sender, GrapeCity.Windows.SpreadSheet.UI.DragFillBlockEventArgs e)
  3.         {
  4.             cacheFillRangeData = gcSpreadSheet1.ActiveSheet.GetArray(e.FillRange.Row, e.FillRange.Column, e.FillRange.RowCount, e.FillRange.ColumnCount);
  5.         }

  6.         private void GcSpreadSheet1_DragFillBlockCompleted(object sender, GrapeCity.Windows.SpreadSheet.UI.DragFillBlockCompletedEventArgs e)
  7.         {
  8.             if (!gcSpreadSheet1.ActiveSheet.RowFilter.IsFiltered)
  9.             {
  10.                 return;
  11.             }
  12.             for (var i = 0; i < e.FillRange.RowCount; i++)
  13.             {
  14.                 int row = e.FillRange.Row + i;
  15.                 if (gcSpreadSheet1.ActiveSheet.RowFilter.IsRowFilteredOut(row))
  16.                 {
  17.                     for (var j = 0; j < e.FillRange.ColumnCount; j++)
  18.                     {
  19.                         int col = e.FillRange.Column + j;
  20.                         gcSpreadSheet1.ActiveSheet.Cells[row, col].Value = cacheFillRangeData[i, j];
  21.                     }
  22.                 }
  23.             }
  24.         }
复制代码
回复 使用道具 举报
pblandscape
初级会员   /  发表于:2017-3-30 14:56:26
板凳
dexteryao 发表于 2017-3-30 09:37
Spread WPF没有提供这样的功能。一个解决方案是在填充前缓存数据,填充后判断如果是被过滤的行就恢复。

有另外一个问题出来了,就是本来我下面的cell是锁定的,也就是不运行他手动修改值的。
结果一拖拉,把下面cell的值替换了,连格式也替换了,
请解决这个问题。
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-3-30 15:21:08
地板
将格式页缓存起来。然后恢复就好了。

  1.         object[,] cacheFillRangeData;
  2.         GrapeCity.Windows.SpreadSheet.Data.StyleInfo[,] cacheFillRangeStyle;
  3.         private void GcSpreadSheet1_DragFillBlock(object sender, GrapeCity.Windows.SpreadSheet.UI.DragFillBlockEventArgs e)
  4.         {
  5.             if (gcSpreadSheet1.ActiveSheet.RowFilter.IsFiltered)
  6.             {
  7.                 cacheFillRangeData = gcSpreadSheet1.ActiveSheet.GetArray(e.FillRange.Row, e.FillRange.Column, e.FillRange.RowCount, e.FillRange.ColumnCount);
  8.                 cacheFillRangeStyle = new GrapeCity.Windows.SpreadSheet.Data.StyleInfo[e.FillRange.Row, e.FillRange.ColumnCount];
  9.                 for (var i = 0; i < e.FillRange.RowCount; i++)
  10.                 {
  11.                     int row = e.FillRange.Row + i;
  12.                     if (gcSpreadSheet1.ActiveSheet.RowFilter.IsRowFilteredOut(row))
  13.                     {
  14.                         for (var j = 0; j < e.FillRange.ColumnCount; j++)
  15.                         {
  16.                             int col = e.FillRange.Column + j;
  17.                             cacheFillRangeStyle[i, j] = gcSpreadSheet1.ActiveSheet.GetStyleInfo(row, col, GrapeCity.Windows.SpreadSheet.Data.SheetArea.Cells);
  18.                         }
  19.                     }
  20.                 }
  21.             }
  22.         }

  23.         private void GcSpreadSheet1_DragFillBlockCompleted(object sender, GrapeCity.Windows.SpreadSheet.UI.DragFillBlockCompletedEventArgs e)
  24.         {
  25.             if (gcSpreadSheet1.ActiveSheet.RowFilter.IsFiltered)
  26.             {
  27.                 for (var i = 0; i < e.FillRange.RowCount; i++)
  28.                 {
  29.                     int row = e.FillRange.Row + i;
  30.                     if (gcSpreadSheet1.ActiveSheet.RowFilter.IsRowFilteredOut(row))
  31.                     {
  32.                         for (var j = 0; j < e.FillRange.ColumnCount; j++)
  33.                         {
  34.                             int col = e.FillRange.Column + j;
  35.                             gcSpreadSheet1.ActiveSheet.Cells[row, col].Value = cacheFillRangeData[i, j];
  36.                             gcSpreadSheet1.ActiveSheet.SetStyleInfo(row, col, cacheFillRangeStyle[i, j]);
  37.                         }
  38.                     }
  39.                 }
  40.                 cacheFillRangeData = null;
  41.                 cacheFillRangeStyle = null;
  42.             }
  43.         }
复制代码
回复 使用道具 举报
pblandscape
初级会员   /  发表于:2017-3-30 15:58:14
5#
dexteryao 发表于 2017-3-30 15:21
将格式页缓存起来。然后恢复就好了。

我的意思是,下面的cells是locked状态的,不允许通过拖拉来改值
回复 使用道具 举报
dexteryao讲师达人认证 悬赏达人认证 SpreadJS 开发认证
超级版主   /  发表于:2017-3-30 16:29:47
6#
这个做不到,在没有设置保护的情况下,locked其实是不起作用的,设置了保护后拖拽只能在连续的没locked区域进行。
如果您想实现不保护还能跨域locked 拖拽,可是参考上面的代码,判断如果单元格是locked也恢复原来的值。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部