本文整理汇总了C#中Employee.setName方法的典型用法代码示例。如果您正苦于以下问题:C# Employee.setName方法的具体用法?C# Employee.setName怎么用?C# Employee.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Employee
的用法示例。
在下文中一共展示了Employee.setName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getListFromSpreadSheet
//Read spreadsheet and return a list
private List<Employee> getListFromSpreadSheet()
{
//open an excel process, then a workbook from the file path
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(path);
//get a worksheet from the workbook and define the range as every cell
Excel._Worksheet xlWorksheet = xlWorkbook.Sheets[1];
Excel.Range xlRange = xlWorksheet.UsedRange;
List<Employee> employeeList = new List<Employee>();
Employee employeeToAdd = new Employee();//temp employee object used to populate the list
/* Used for testing
try
{
for(int i = 1; i <= xlRange.Rows.Count; ++i)
{
for(int j = 1; j <= xlRange.Columns.Count; ++j)
{
Console.WriteLine(xlRange.Cells[i, j].Value2.ToString());
}
}
}
catch(Exception err)
{
Console.WriteLine(err.Message);
}
*/
try
{
// iterate through each cell in a row
for(int i = 2; i <= xlRange.Rows.Count; ++i)
{
employeeToAdd = new Employee();
for(int j = 1; j <= xlRange.Columns.Count; ++j)
{
// each if here checks the first row for a column name
// if the name matches an employee property, it adds
// the value of the current row to the respective property
if(xlRange.Cells[1,j].Value2.ToString().Equals("Name"))
{
employeeToAdd.setName(xlRange.Cells[i, j].Value2.ToString());
}
if (xlRange.Cells[1, j].Value2.ToString().Equals("Aht"))
{
employeeToAdd.setAht((int)xlRange.Cells[i, j].Value2);
}
if (xlRange.Cells[1, j].Value2.ToString().Equals("Adherence"))
{
employeeToAdd.setAdherence((Decimal)xlRange.Cells[i, j].Value2);
}
if (xlRange.Cells[1, j].Value2.ToString().Equals("Knowledge"))
{
employeeToAdd.setKnowledge((Decimal)xlRange.Cells[i, j].Value2);
}
if (xlRange.Cells[1, j].Value2.ToString().Equals("Quality"))
{
employeeToAdd.setQuality((Decimal)xlRange.Cells[i, j].Value2);
}
}
//add completed employee to the list
employeeList.Add(employeeToAdd);
}
}
catch(Exception err)
{
Console.WriteLine(err.Message);
}
// Close everything up and kill excel process
xlWorkbook.Close(0);
xlApp.Quit();
killExcel();
return employeeList;
}