简体   繁体   English

如何获取 Excel VSTO C# 中已删除范围的值

[英]How do I get the values of a deleted range in Excel VSTO C#

Sheet Change Event 工作表更改事件

The Target Range refers to the range values referred to by the address of the deleted row.目标范围是指被删除行的地址所引用的范围值。 I need the Range values that were just deleted.我需要刚刚删除的范围值。 How can I do this?我怎样才能做到这一点?

In _Application_SheetActivate在 _Application_SheetActivate

dataArray = ((Excel.Worksheet)Sh).UsedRange.Value2;

In Application_SheetChange(object Sh, Excel.Range Target)在 Application_SheetChange(对象 Sh,Excel.Range 目标)

var deletedRow = _dataArray.ToJaggedArray();
var values = deletedRow[Target.Row - 1];
        public static object[][] ToJaggedArray(this object[,] array)
        {
            object[][] jagged = new object[array.GetLength(0)][];

            for (int i = 0; i < array.GetLength(0); i++)
            {
                jagged[i] = new object[array.GetLength(1)];
                for (int j = 1; j <= array.GetLength(1); j++)
                {
                    jagged[i][j - 1] = array[i + 1, j];
                }
            }

            return jagged;
        }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在VSTO / C#中使用行号和列号获取Excel范围? - How do I get an Excel range using row and column numbers in VSTO / C#? C#Excel VSTO:get_Range()和Range()之间的区别 - C# Excel VSTO: Difference between get_Range() and Range() 在 Excel 和 C# 中给定起点的情况下,如何获得包含 X 行和 Y 行的范围? - How can I get a Range incorporating X rows and Y rows given a starting point in Excel with VSTO & C#? 如何在Excel中仅读取具有特定范围内的值的单元格-使用VSTO C# - How to only read cells with values with in a specific range in Excel - using VSTO C# 如何让用户在 c# vsto excel 加载项中选择单元格(范围输入)? - How to get user to select cells(Range input) in c# vsto excel add-in? 如何在 C# / VSTO 中为 Excel 数据 Model 连接指定使用 XlCmdType.xlCmdTableCollection 的表 - How do I specify the tables using XlCmdType.xlCmdTableCollection for an Excel Data Model connection in C# / VSTO 如何通过使用VSTO获得有效的Excel范围? - How to get the active excel range by using VSTO? 如何从Excel范围中删除重复项? C# - How do I remove duplicates from excel range? c# 如何在C#中的Excel范围内找到关键字? - How do I find out a keyword in a range of a excel in C#? C#VSTO Excel NamedRange更改事件:迭代范围 - C# VSTO Excel NamedRange Change event: Iterate the range
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM