1

给定以下代码:

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

如何评估单元格 [0,0] 中的公式?

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

1 回答 1

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;
于 2009-12-09T19:46:24.903 回答