繁体   English   中英

使用 Aspose Cells,如何在不格式化的情况下将 Cell 公式复制到另一个单元格并在.Net Core 中更新其引用

[英]With Aspose Cells, how to copy a Cell formula to another cell and update its references in .Net Core without its formating

我正在使用带有 .net 核心的 Aspose Cells。

我想将一个单元格公式复制到另一个单元格,并使用其新的“位置”更新公式中的单元格引用。

如果我使用cell.copy它正在工作,但它也是单元格属性的副本,例如“锁定”。

有办法解决吗?

就像使用 MS-Excel 时一样,您执行“仅特殊粘贴公式”

我在 Aspose 论坛上发布了我的问题,并得到了 Amjad Sahi 的快速回答

https://forum.aspose.com/t/copy-formula-from-a-cell-to-another-with-updated-references-without-the-source-cell-attribute-like-locked/239996/2

它对我有用。

我最终得到了这个:

    public void CopyFormulaFrom(ICell cell)
    {
        var cells = cell.Sheet.Name == Sheet.Name
            ? _cell.Worksheet.Cells
            : _cell.Worksheet.Workbook.Worksheets[cell.Sheet.Name]?.Cells;

        var cellSource = cells.CreateRange(cell.Row, cell.Column, 1, 1);
        var cellDestination = cells.CreateRange(_cell.Row, _cell.Column, 1, 1);
        
        var options = new PasteOptions() { PasteType = PasteType.Formulas };

        cellDestination.Copy(cellSource, options);
    }

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM