public static int TestGetRanges(string formula) { // mock workbook object var mwb = new MockWorkbook(); Excel.Workbook wb = mwb.GetWorkbook(); Excel.Worksheet ws = mwb.GetWorksheet(1); var path = Microsoft.FSharp.Core.FSharpOption <string> .None; var ranges = ExcelParserUtility.GetRangeReferencesFromFormulaRaw(formula, path, wb, ws, ignore_parse_errors: false); return(ranges.Count()); }
private readonly long _analysis_time; // amount of time to run dependence analysis public DAG(Excel.Workbook wb, Excel.Application app, bool ignore_parse_errors) { // start stopwatch var sw = new System.Diagnostics.Stopwatch(); sw.Start(); // get application reference _app = app; // bulk read worksheets fastFormulaRead(wb); // extract references from formulas foreach (AST.Address formula_addr in this.getAllFormulaAddrs()) { // get COMRef read earlier var formula_ref = this.getCOMRefForAddress(formula_addr); foreach (AST.Range vector_rng in ExcelParserUtility.GetRangeReferencesFromFormula(formula_ref, ignore_parse_errors)) { // fetch/create COMRef, as appropriate var vector_ref = this.makeInputVectorCOMRef(vector_rng); // link formula and input vector this.linkInputVector(formula_addr, vector_rng); // link input vector to the vector's single inputs foreach (AST.Address input_single in vector_rng.Addresses()) { this.linkComponentInputCell(vector_rng, input_single); } // if num single inputs = num formulas, // mark vector as non-perturbable this.markPerturbability(vector_rng); } foreach (AST.Address input_single in ExcelParserUtility.GetSingleCellReferencesFromFormula(formula_ref, ignore_parse_errors)) { // link formula and single input this.linkSingleCellInput(formula_addr, input_single); } } // stop stopwatch sw.Stop(); _analysis_time = sw.ElapsedMilliseconds; }