本文整理汇总了C#中Microsoft.Office.Interop.Excel.get_Item方法的典型用法代码示例。如果您正苦于以下问题:C# Microsoft.Office.Interop.Excel.get_Item方法的具体用法?C# Microsoft.Office.Interop.Excel.get_Item怎么用?C# Microsoft.Office.Interop.Excel.get_Item使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Office.Interop.Excel
的用法示例。
在下文中一共展示了Microsoft.Office.Interop.Excel.get_Item方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSheet
//获取一个工作表
/// <summary>
/// 获得sheet
/// </summary>
/// <param name="sheets">sheet</param>
/// <param name="sc">序号</param>
public Excel._Worksheet GetSheet(Excel.Sheets sheets, int sc)
{
Excel._Worksheet worksheet = (Microsoft.Office.Interop.Excel._Worksheet)sheets.get_Item(sc);
return worksheet;
}
示例2: CheckAllProfiles
static private bool CheckAllProfiles(Hashtable oldBook, Excel.Sheets newSheets)
{
try
{
Hashtable oldRows = new Hashtable();
Hashtable newRows = new Hashtable();
Excel.Worksheet saveSheet = null;
#region Läs in alla nya, och hitta sheetet "AllProfiles"
//Läs in alla nya
int numOfNewSheets = _newLog.Worksheets.Count;
//// get the first worksheet from the collection of worksheets
Excel.Worksheet newWorksheet = null;// (Excel.Worksheet)newSheets.get_Item(1);
//// loop through 10 rows of the spreadsheet and place each row in the list view
//_compareProgress.StartTotal("Loading new AllProfiles Log sheets and compares...", numOfNewSheets);//-1 );
//int sheetsDone = 0;//För progress
//Compare to old rows
for (int sheetNr = 1; sheetNr <= numOfNewSheets; sheetNr++)
{
//if (MainForm.StopGracefully)
// break;
string name = ((Excel.Worksheet)newSheets.get_Item(sheetNr)).Name;
newWorksheet = (Excel.Worksheet)newSheets.get_Item(sheetNr);
//Läs in hela nuv. nya arket till en HT
if (name.StartsWith("AllProfiles"))//Specialfall för AllProfiles-flikar
getExcelRows(newWorksheet, newRows);
if (name == "AllProfiles")
saveSheet = newWorksheet;
//Ev. Rensa _part1...X
//_compareProgress.SetTotal(sheetsDone++);
}
#endregion
#region Lägg ihop alla gamla
oldRows = oldBook["AllProfiles"] as Hashtable;
foreach (DictionaryEntry item in oldBook)
{
string name = item.Key as string;
Hashtable rows = item.Value as Hashtable;
//if (name == "AllProfiles")//Specialfall för AllProfiles-flikar
//{
// oldRows = rows;
//}
if (name.StartsWith("AllProfiles_"))//Specialfall för AllProfiles-flikar
{
foreach (DictionaryEntry innerItem in rows)
{
if (oldRows.ContainsKey(innerItem.Key as string))
{
//Här finns en dublett! Det ska ladrig inträffa, för det ska vara unika som läggs till, även om det iofs är olika blad
Console.WriteLine("Double fond in CheckAllProfiles old rows: " + name + ". Key: >" + innerItem.Key as string + "<");
}
else
oldRows.Add(innerItem.Key as string, innerItem.Value as ExcelRowEntry);
}
}
}
#endregion
compareExcelRows(saveSheet, oldRows, newRows);
}
catch (Exception allPexcp)
{
throw new Exception("Error in comparing AllProfiles log with new log. Was the log opened in Excel during compare processing?\r\n\r\n(Sys err: " + allPexcp.Message + ").", allPexcp);
}
return true;
}