示例#1
0
 private void btnParse_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
 {
     #region #parse
     FormulaEngine engine = spreadsheetControl1.Document.FormulaEngine;
     if (spreadsheetControl1.ActiveCell != null)
     {
         // Get the formula for parsing.
         string formula = spreadsheetControl1.ActiveCell.Formula;
         if (formula != string.Empty)
         {
             // Parse the formula
             ParsedExpression p_expr = engine.Parse(formula);
             // Traverse the expression tree and modify it.
             MyVisitor visitor = new MyVisitor();
             p_expr.Expression.Visit(visitor);
             // Reconsitute the formula.
             string formula1 = p_expr.ToString();
             // Place the formula back to the cell.
             spreadsheetControl1.ActiveCell.Formula = formula1;
         }
         #endregion #parse
     }
 }