本文整理汇总了C#中Microsoft.Office.Interop.Excel.Worksheet.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Worksheet.Select方法的具体用法?C# Worksheet.Select怎么用?C# Worksheet.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel.Worksheet
的用法示例。
在下文中一共展示了Worksheet.Select方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetVisibleFormExcel
static void GetVisibleFormExcel()
{
//Console.WriteLine("please choose Excel File");
//OpenFileDialog ofD = new OpenFileDialog(); ofD.ShowDialog();
//string fName = ofD.FileName;
//Excel.Application xApp = new Excel.Application();
//xApp.Visible = true;
//Excel.Workbook xbook = xApp.Workbooks.Open("C:\\share\\temp.xlsx");
xSheet = xbook.Sheets[2];
xSheet.Select();
Excel.Range xRange = null;
string appKeyStr = null; string visibleStr = null;
int i = 2;
xRange = xSheet.Cells[i, 1]; appKeyStr = xRange.Value2;
while (!String.IsNullOrEmpty(appKeyStr))
{
appKeyArr.Add(appKeyStr.ToString().Trim());
xRange = xSheet.Cells[i, 3]; visibleStr = xRange.Value2.ToString().Trim(); VisibleArr.Add(visibleStr);
//Console.WriteLine("Name:{0} IE:{1} FireFox:{2} Chrome:{3}", appName,ie,firefox,chrome);
i++;
xRange = xSheet.Cells[i, 1]; appKeyStr = xRange.Value2;
}
//Console.WriteLine("Done");
xSheet = null;
//xbook = null; xApp.Quit(); xApp = null;
}
示例2: ExcelOperator
//for writing
public ExcelOperator()
{
ExcelApp = new Excel.Application();
workbooks = ExcelApp.Workbooks;
workbook = workbooks.Add();
sheets = workbook.Sheets;
worksheet = sheets[1];
worksheet.Select(Type.Missing);
directoryPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
fileName = "shift.xlsx";
}
示例3: CreateNewPage
/// <summary>
/// Creates a new page with a given name (if Excel)
/// </summary>
/// <param name="worksheetName"></param>
public override void CreateNewPage(string worksheetName)
{
// post format the previous document
this.CreateDocumentSpecificPostFormatting();
// worksheet information
worksheet = (Excel.Worksheet)workbook.Worksheets.Add(Type.Missing, worksheet);
worksheet.Select();
worksheet.Name = worksheetName;
// excel positioning vars
this.starterRow = 1;
this.currentRow = 2;
this.currentColumnCount = 4;
this.currentColumnOffset = 2;
// rem grid lines
app.ActiveWindow.DisplayGridlines = false;
}
示例4: UpdateToMasterList
static void UpdateToMasterList()
{
//Console.WriteLine("please choose Excel File");
//OpenFileDialog ofD = new OpenFileDialog(); ofD.ShowDialog();
//string fName = ofD.FileName;
//Excel.Application xApp = new Excel.Application();
//xApp.Visible = true;
//Excel.Workbook xbook = xApp.Workbooks.Open("C:\\share\\temp.xlsx");
xSheet = xbook.Sheets[1];
xSheet.Select();
Excel.Range xRange = null;
string appNameStr = null; string visibleStr = null; string appKeyStr = null;
int i = 2;
xRange = xSheet.Cells[i, 1]; appNameStr = xRange.Value2;
while (!String.IsNullOrEmpty(appNameStr))
{
xRange = xSheet.Cells[i, 6]; appKeyStr = xRange.Value2;
if (!String.IsNullOrEmpty(appKeyStr))
{
visibleStr = GetVisibleByAppKeyStr(appKeyStr.ToString().Trim());
xRange = xSheet.Cells[i, 7]; xRange.Value2 = visibleStr.ToString();
}
i++;
xRange = xSheet.Cells[i, 1]; appNameStr = xRange.Value2;
}
//Console.WriteLine("Done");
xSheet = null;
// xSheet = null; xbook = null; xApp.Quit(); xApp = null;
}