Aspose-Cells:我如何评估公式?

时间:2009-12-09 16:34:45

标签: aspose aspose-cells

给出以下代码:

using Aspose.Cells
// {...}  
Workbook workbook = new Workbook();  
Worksheet virtualWorksheet = workbook.Worksheets[0];  
virtualWorksheet.Cells[0, 0].Formula ="=1<2";

如何评估Cell [0,0]中的公式?

bool isCellTrue = virtualWorksheet.Cells[0, 0].BoolValue; // will generate an exception at run-time

1 个答案:

答案 0 :(得分:1)

来自:http://www.aspose.com/community/forums/permalink/212217/212232/showthread.aspx#212232

调用Workbook.CalculateFormula()方法在运行时获取/检索计算值之前计算工作簿中的所有公式,例如

Workbook workbook = new Workbook(); 
Worksheet virtualWorksheet = workbook.Worksheets[0]; 
virtualWorksheet.Cells[0, 0].Formula ="=1<2";
workbook.CalculateFormula(); 
bool isCellTrue = virtualWorksheet.Cells[0, 0].BoolValue;