示例#1
0
        private void ProcessDuplicateRows(string worksheetName, DuplicateRowAction deleteAction, DuplicateRowAction hilightAction)
        {
            Worksheet ws = Globals.ThisAddIn.Application.ActiveWorkbook.Sheets[worksheetName];

            long previousITR = 0;
            long currentITR  = 0;
            int  lastITRrow  = ws.Range["B5"].SpecialCells(XlCellType.xlCellTypeLastCell).Row;

            // and then walk the list of ITRs and delete duplicates
            //Debug.Print(lastITRrow);

            for (int i = lastITRrow; i >= Common.cFirstITRRow; i += -1)
            {
                //Debug.Print(String.Format("previousITR {0}  currentITR {1}   i {2}  lastITRRow {3}", _
                //    previousITR, ws.Cells[i, Common.cITRID_COLUMN].Value, i, lastITRrow))
                currentITR = Convert.ToInt64(ws.Cells[i, Common.cITRID_COLUMN].Value);

                if (currentITR == previousITR)
                {
                    //Debug.Print("Matching ITR")
                    // First hilight the previous matching ITR
                    hilightAction(ws, i + 1);
                    // Then take the deleteAction on the current row.  This might be a hilight operation.
                    deleteAction(ws, i);
                    lastITRrow = lastITRrow - 1;
                }
                else
                {
                    //Debug.Print("New ITR")
                }

                previousITR = currentITR;
            }
        }
示例#2
0
        public void RemoveDuplicateRows(string worksheetName, DuplicateRowAction action)
        {
            Worksheet ws = Globals.ThisAddIn.Application.ActiveWorkbook.Sheets[worksheetName];

            ws.Columns[Common.cRESOURCEID_COLUMN].Delete();

            long previousITR   = 0;
            long currentITR    = 0;
            int  lastITRrow    = 0;
            bool foundMatching = false;

            lastITRrow = ws.Range["B5"].SpecialCells(XlCellType.xlCellTypeLastCell).Row;
            // and then walk the list of ITRs and delete duplicates
            //Debug.Print(lastITRrow);

            for (int i = lastITRrow; i >= Common.cFirstITRRow; i += -1)
            {
                //Debug.Print(string.Format("previousITR {0}  currentITR {1}   i {2}  lastITRRow {3}", previousITR, ws.Cells[i, Common.cITRID_COLUMN].Value, i, lastITRrow));
                currentITR = Convert.ToInt64(ws.Cells[i, Common.cITRID_COLUMN].Value);

                if (currentITR == previousITR)
                {
                    //Debug.Print("Matching ITR");
                    DeleteRow(ws, i);
                    lastITRrow = lastITRrow - 1;

                    if (!foundMatching)
                    {
                        // Hilight the previous row which matched the current row.
                        HilightRow(ws, i - 1);
                    }

                    foundMatching = true;
                }
                else
                {
                    //Debug.Print("New ITR");
                    foundMatching = false;
                }

                previousITR = currentITR;
            }
        }