private void validateRecalc_Click(object sender, System.EventArgs e) { if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } XlsFile Xls = new XlsFile(); Xls.Open(openFileDialog1.FileName); // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // ////////Code here is only needed if you have linked files. In this example we don't know, so we will use it ///////// TWorkspace Work = new TWorkspace(); //Create a workspace Work.Add(Path.GetFileName(openFileDialog1.FileName), Xls); //Add the original file to it Work.LoadLinkedFile += new LoadLinkedFileEventHandler(Work_LoadLinkedFile); //Set up an event to load the linked files. // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// report.Text = "Results on file: " + openFileDialog1.FileName; TUnsupportedFormulaList Usl = Xls.RecalcAndVerify(); if (Usl.Count == 0) { report.Text += "\n**********All formulas supported!**********"; return; } report.Text += "\nIssues Found:"; for (int i = 0; i < Usl.Count; i++) { string FileName = String.Empty; if (Usl[i].FileName != null) { FileName = "File: " + Usl[i].FileName + " => "; } report.Text += "\n " + FileName + Usl[i].Cell.CellRef + ": " + Usl[i].ErrorType.ToString(); if (Usl[i].StackTrace != null) { for (int k = 0; k < Usl[i].StackTrace.Length; k++) { if (Usl[i].StackTrace[k].Address != null) { String TraceFileName = Usl[i].StackTrace[k].FileName == null ? "" : "[" + Usl[i].StackTrace[k].FileName + "]"; report.Text += "\n -> References cell: " + TraceFileName + Usl[i].StackTrace[k].Address.CellRef; } } } if (Usl[i].FunctionName != null) { string FunctionStr = "Function"; if (Usl[i].ErrorType == TUnsupportedFormulaErrorType.ExternalReference) { FunctionStr = "Linked file not found"; } report.Text += " ->" + FunctionStr + ": " + Usl[i].FunctionName; } } }
private void ValidateXls(XlsFile xls, DataTable table) { TUnsupportedFormulaList Usl = xls.RecalcAndVerify(); for (int i = 0; i < Usl.Count; i++) { table.Rows.Add(new object[] { Usl[i].FileName, Usl[i].Cell.CellRef, Usl[i].ErrorType.ToString(), Usl[i].FunctionName }); } }
internal void Recalc(ExcelFile aXls, TUnsupportedFormulaList Ufl) { aXls.SetUnsupportedFormulaList(Ufl); try { int aCount = Sheets.Count; for (int i = 0; i < aCount; i++) { Sheets[i].Cells.CellList.Recalc(aXls, i + 1); } } finally { aXls.SetUnsupportedFormulaList(null); } }