[英]How to copy one worksheet to another worksheet on within workbook using aspose.cell
[英]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 的快速回答
它对我有用。
我最终得到了这个:
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.