当前位置: 首页>>代码示例>>C#>>正文


C# Employee.setAdherence方法代码示例

本文整理汇总了C#中Employee.setAdherence方法的典型用法代码示例。如果您正苦于以下问题:C# Employee.setAdherence方法的具体用法?C# Employee.setAdherence怎么用?C# Employee.setAdherence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Employee的用法示例。


在下文中一共展示了Employee.setAdherence方法的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;
        }
开发者ID:Mayme123,项目名称:GrangeScoreCard,代码行数:88,代码来源:ExcelParser.cs


注:本文中的Employee.setAdherence方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。