本文整理汇总了C#中Microsoft.Office.Interop.Excel.Application.Run方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Excel.Application.Run方法的具体用法?C# Microsoft.Office.Interop.Excel.Application.Run怎么用?C# Microsoft.Office.Interop.Excel.Application.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel.Application
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Excel.Application.Run方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BackgroundWorker_DoWork
public void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
Data data = (Data) e.Argument; // Cast e argument to a local Data instance
// Start Excel/Multiframe calls - Either 11 or 20 stages, depending on debugMode (11 is debugMode, skips creating frame. Does debug info only)
bool debugMode = Properties.Settings.Default.DebugMode;
int progressTotal = debugMode == true ? 11 : 20;
int progressCount = 0;
bool unableToAddQ2Loads = false;
try
{
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Opening Excel"); progressCount++;
excelApp = new Microsoft.Office.Interop.Excel.Application();
excelApp.Visible = Properties.Settings.Default.DisplayExcel;
excelApp.DisplayAlerts = false;
wb = excelApp.Workbooks.Open(fileName);
ws = wb.Sheets.get_Item(1); // Expects "Input" sheet to be the first worksheet
// Insert values into Excel Inputs Sheet
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Inserting values into Input Sheet"); progressCount++;
ws.Range["windSpeedVu"].Value = data.ultimateWindSpeed;
ws.Range["windSpeedVs"].Value = data.serviceWindSpeed;
ws.Range["internalPressure"].Value = data.internalPressure;
ws.Range["shedType"].Value = data.roofType;
ws.Range["shedWallType"].Value = data.wallType;
ws.Range["shedEaveHeight"].Value = data.eaveHeight;
ws.Range["shedRoofPitch"].Value = data.roofPitch;
ws.Range["shedSpan"].Value = data.span;
ws.Range["shedBaySpacing"].Value = data.baySpacing;
ws.Range["shedNumberOfBays"].Value = data.numberOfBays;
ws.Range["shedSupports"].Value = data.supports;
ws.Range["shedEndColumnType"].Value = data.endColumnType;
ws.Range["shedEndColumnSection"].Value = data.endColumnSection;
ws.Range["shedEndRafterType"].Value = data.endRafterType;
ws.Range["shedEndRafterSection"].Value = data.endRafterSection;
ws.Range["shedMidColumnType"].Value = data.midColumnType;
ws.Range["shedMidColumnSection"].Value = data.midColumnSection;
ws.Range["shedMidRafterType"].Value = data.midRafterType;
ws.Range["shedMidRafterSection"].Value = data.midRafterSection;
ws.Range["shedMullions"].Value = data.numberOfMullions;
ws.Range["shedMullionsType"].Value = data.mullionType;
ws.Range["shedMullionsSection"].Value = data.mullionSection;
ws.Range["shedCompressionStrutType"].Value = data.strutType;
ws.Range["shedCompressionStrutSection"].Value = data.strutSection;
ws.Range["shedKneeBraceEnd"].Value = data.endKneeBraceType == "None" ? "no" : "yes";
if (data.endKneeBraceType != "None")
{
ws.Range["shedKneeBraceEndType"].Value = data.endKneeBraceType;
ws.Range["shedKneeBraceEndSection"].Value = data.endKneeBraceSection;
}
ws.Range["shedKneeBraceMid"].Value = data.midKneeBraceType == "None" ? "no" : "yes";
if (data.midKneeBraceType != "None")
{
ws.Range["shedKneeBraceMidType"].Value = data.midKneeBraceType;
ws.Range["shedKneeBraceMidSection"].Value = data.midKneeBraceSection;
}
ws.Range["shedKneeBracePercentEave"].Value = data.kneeBracePercentEave;
ws.Range["shedKneeBracePercentSpan"].Value = data.kneeBracePercentSpan;
ws.Range["shedApexBraceEnd"].Value = data.endApexBraceType == "None" ? "no" : "yes";
if (data.endApexBraceType != "None")
{
ws.Range["shedApexBraceEndType"].Value = data.endApexBraceType;
ws.Range["shedApexBraceEndSection"].Value = data.endApexBraceSection;
}
ws.Range["shedApexBraceMid"].Value = data.midApexBraceType == "None" ? "no" : "yes";
if (data.midApexBraceType != "None")
{
ws.Range["shedApexBraceMidType"].Value = data.midApexBraceType;
ws.Range["shedApexBraceMidSection"].Value = data.midApexBraceSection;
}
ws.Range["shedEavePurlinType"].Value = data.eavePurlinType;
ws.Range["shedEavePurlinSection"].Value = data.eavePurlinSection;
ws.Range["shedRoofPurlinType"].Value = data.strutType;
ws.Range["shedRoofPurlinSection"].Value = data.strutSection;
// Start calling macros from Excel Workbook
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Setting initial excel values"); progressCount++;
excelApp.Run("CsharpSetExcelInputValues");
if (debugMode == false)
{
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Setting units in Multiframe"); progressCount++;
excelApp.Run("CsharpSetUnits");
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Creating Frame"); progressCount++;
excelApp.Run("CsharpCreateFrame");
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Creating Knee Braces"); progressCount++;
excelApp.Run("CsharpAddKneeBraces");
bw.ReportProgress((int)(((double)progressCount / (double)progressTotal) * 100), "Creating Apex Braces"); progressCount++;
//.........这里部分代码省略.........