开发者

Aspose-Cells: How do I evaluate a formula?

开发者 https://www.devze.com 2022-12-13 12:03 出处:网络
Given the following code: using Aspose.Cells // {...} Workbook workbook = new Workbook(); Worksheet virtualWorksheet = workbook.Worksheets[0];

Given the following code:

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

How do I evaluate the formula in Cell [0,0]?

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


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

Call Workbook.CalculateFormula() method to calculate all the formulas in the workbook before getting/retrieving the calculated value at runtime, e.g.

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;
0

精彩评论

暂无评论...
验证码 换一张
取 消