本文整理汇总了C#中Application.CalculateFullRebuild方法的典型用法代码示例。如果您正苦于以下问题:C# Application.CalculateFullRebuild方法的具体用法?C# Application.CalculateFullRebuild怎么用?C# Application.CalculateFullRebuild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Application
的用法示例。
在下文中一共展示了Application.CalculateFullRebuild方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExcelTest
public void ExcelTest(string workbook)
{
var outDir = Path.GetDirectoryName(new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);
m_xlApp = new Application();
Assert.IsNotNull(m_xlApp, "Could not create an Excel Application object");
var xlWorkbooks = m_xlApp.Workbooks;
var testMacrosPath = Path.Combine(outDir, "testMacros.xlsm");
var testMacros = xlWorkbooks.Open(testMacrosPath, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
var pidAsObject = m_xlApp.Run(testMacros.Name + "!getpid");
m_xlProcess = Process.GetProcessById(pidAsObject);
var xldnaToLoad = PrepareXlDna(outDir);
workbook = Path.Combine(outDir, "testWorkbooks", workbook);
var workbookName = Path.GetFileName(workbook);
Assert.IsTrue(File.Exists(workbook));
Assert.IsTrue(m_xlApp.RegisterXLL(xldnaToLoad));
m_xlApp.DisplayAlerts = false;
m_xlWorkbook = xlWorkbooks.Open(workbook, 0, true, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
var workDir = Path.Combine(outDir, "evidence");
if (!Directory.Exists(workDir))
{
try { Directory.CreateDirectory(workDir); } catch (Exception) { }; // more than 1 thread might get here, but only 1 will succeed
}
Assert.IsTrue(Directory.Exists(workDir));
m_xlApp.Run(testMacros.Name + "!setProcessCurrentDirectory", workDir);
m_xlApp.CalculateBeforeSave = false;
bool vbaResult = false;
try
{
vbaResult = m_xlApp.Run(m_xlWorkbook.Name + "!VBATest");
}
catch (COMException x)
{
// This HR means "Programmatic access to Visual Basic is not trusted"
// It is returned also in case the macro does not exist
// If we get anything other than this type of error, we rethrow.
// Otherwise there's nothing to test and we carry on.
if ((uint)x.HResult != 0x800a03ec)
throw;
vbaResult = true;
}
Assert.IsTrue(vbaResult);
Range resultRange = m_xlApp.Range["RESULT"];
Assert.AreEqual(1, resultRange.Count);
resultRange.Dirty();
m_xlApp.CalculateFullRebuild();
dynamic testResult = resultRange.Value;
if (typeof(int) == testResult.GetType())
Assert.Fail("RESULT={0}", hashErrorToString((uint)testResult));
Assert.AreEqual(typeof(bool), testResult.GetType(), "RESULT={0}", testResult.ToString());
Assert.IsTrue((bool)testResult);
// the test has passed. we don't need to leave the xlsm around
m_xlWorkbook.Close(false);
m_xlWorkbook = null;
File.Delete(workbook);
}