数据表的数组公式计算
Contents
[
Hide
]
您可以在Microsoft Excel中使用数据>数据表…来创建数据表。 Aspose.Cells现在允许您计算数据表的数组公式。请在计算任何类型的公式时使用Workbook.CalculateFormula()。
在以下示例代码中,我们使用了source excel file。如果您将单元格B1的值更改为100,则填充为黄色的数据表的值将变为120,如下图所示。 示例代码生成了output PDF。
以下是用于从source excel file生成output PDF的示例代码。 请阅读注释以获取更多信息。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook from source excel file | |
Workbook workbook = new Workbook(dataDir + "DataTable.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// When you will put 100 in B1, then all Data Table values formatted as Yellow will become 120 | |
worksheet.Cells["B1"].PutValue(100); | |
// Calculate formula, now it also calculates Data Table array formula | |
workbook.CalculateFormula(); | |
// Save the workbook in pdf format | |
workbook.Save(dataDir + "output_out.pdf"); |