在 excel 中复制并向下移动单元格

问题描述 投票:0回答:0

我需要有关多年前编写的代码的帮助。

    public void Copy(Range range, string Cell)
    {
        Range RngToInsert = worksheet.get_Range(Cell, Type.Missing).EntireRow;
        RngToInsert.Insert(XlInsertShiftDirection.xlShiftDown, range.Copy(Type.Missing));
    }

基本上,我想了解这段代码的作用以及我如何使用 Aspose.Cells 实现相同的目的。

到目前为止,我做了这个,但我认为它与上述功能还差得远。

    public static void Copy(this Worksheet worksheet, Range range, string cell)
    {
        CellsHelper.CellNameToIndex(cell, out int row, out int column);
        CellArea area = CellArea.CreateCellArea(
                range.FirstRow,
                range.FirstColumn,
                range.FirstRow + range.RowCount,
                range.ColumnCount);
        worksheet.Cells.InsertRange(area, range.RowCount, ShiftType.Down, true);
        worksheet.Cells.InsertRows(row, range.RowCount);
    }
c# excel excel-interop aspose-cells interopservices
© www.soinside.com 2019 - 2024. All rights reserved.