Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
291 views
in Technique[技术] by (71.8m points)

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?

question from:https://stackoverflow.com/questions/65904541/how-do-i-get-the-values-of-a-deleted-range-in-excel-vsto-c-sharp

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

In _Application_SheetActivate

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

In Application_SheetChange(object Sh, Excel.Range Target)

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;
        }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...