在Aspose.Cells中设置公式中的外部链接
Contents
[
Hide
]
有时,有必要在公式中包含对外部文件的链接,例如针对它们评估单元格或范围值。Aspose.Cells提供了这个功能,并且本文档解释了如何使用它。
下面的示例代码显示了如何在公式中包含外部文件。
C#
string FilePath = @"..\..\..\Sample Files\";
string FileName = FilePath + "Set External Links in Formula.xlsx";
//Instantiate a new Workbook.
Workbook workbook = new Workbook();
//Get first Worksheet
Worksheet sheet = workbook.Worksheets[0];
//Get Cells collection
Aspose.Cells.Cells cells = sheet.Cells;
//Set formula with external links
cells["A1"].Formula = "=SUM('[book1.xls]Sheet1'!A2, '[book1.xls]Sheet1'!A4)";
//Set formula with external links
cells["A2"].Formula = "='[book1.xls]Sheet1'!A8";
//Save the workbook
workbook.Save(FileName);