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


C# Sheet.GetRowEnumerator方法代码示例

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


在下文中一共展示了Sheet.GetRowEnumerator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportYkpt

        /// <summary>
        /// 导入 从业扩配套表格中
        /// </summary>
        /// <param name="sheet"></param>
        /// <param name="prjtype"> </param>
        private void ImportYkpt(Sheet sheet, string prjtype)
        {
            var rows = sheet.GetRowEnumerator();
            rows.MoveNext();
            while (rows.MoveNext())
            {
                var row = (HSSFRow)rows.Current;
                var cell = row.GetCell(7);
                if (cell == null) continue;
                cell.SetCellType(CellType.STRING);
                var erpaccount = cell.StringCellValue.Trim();
                if (string.IsNullOrEmpty(erpaccount)) continue;// 如果没有erp账号不导入
                var account = erpaccount; // 业扩配套项目没有子账号,账号和erp编码一致

                cell = row.GetCell(8);
                if (cell != null)
                    cell.SetCellType(CellType.STRING);
                else continue;
                var prjname = cell.StringCellValue.Trim();
                if (string.IsNullOrEmpty(prjname)) continue; //没有工程名称 不导入
                const string voltage = "10KV";
                // 获取施工合同乙方单位名称
                cell = row.GetCell(6);
                var contractcompanyName = cell.StringCellValue.Trim();

                // 获取施工合同分包商名称
                cell = row.GetCell(5);
                var subcompanyName = cell.StringCellValue.Trim();

                var htbh = "";
                cell = row.GetCell(2);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString().Trim()))
                {
                    cell.SetCellType(CellType.NUMERIC);
            // ReSharper disable SpecifyACultureInStringConversionExplicitly
                    htbh = cell.NumericCellValue.ToString();
            // ReSharper restore SpecifyACultureInStringConversionExplicitly
                }

                DateTime? recievedesigndrawingdate  = null;
                cell = row.GetCell(0);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                  //  cell.SetCellType(CellType.STRING);
                    recievedesigndrawingdate = cell.DateCellValue; // 设计图纸到达日期

                double? contractamount = null;
                cell = row.GetCell(22);
                if (cell != null )
                {
                    cell.SetCellType(CellType.FORMULA);
                    contractamount = cell.NumericCellValue; //承包合同价(预算价)
                }

                double? aqcsfee=null;
                cell = row.GetCell(1);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                {
                    cell.SetCellType(CellType.NUMERIC);
                    aqcsfee = cell.NumericCellValue; // 安全措施费
                }

                double? gxchfee = null;
                cell = row.GetCell(16);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                {
                    cell.SetCellType(CellType.NUMERIC);
                    gxchfee = cell.NumericCellValue; // 管线测绘费
                }

                double? sumfee = null;
                cell = row.GetCell(13);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                {
                    cell.SetCellType(CellType.NUMERIC);
                    sumfee = cell.NumericCellValue; // 管线测绘费
                }

                DateTime? planstartdate = null;
                DateTime? planenddate = null;
                cell = row.GetCell(10);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                {

                    var strduration = cell.StringCellValue.Trim();
                    string[] datesstr = strduration.Split(new char[] { '-' });
                    string[] monthday = datesstr[0].Split(new char[] { '.' });
                    string[] monthday1 = datesstr[1].Split(new char[] { '.' });

                    planstartdate = new DateTime(DateTime.Today.Year, Convert.ToInt32(monthday[0]), Convert.ToInt32(monthday[1])); // 计划开工日期
                    planenddate = monthday1.Count() == 3 ? new DateTime(Convert.ToInt32(monthday1[0]), Convert.ToInt32(monthday1[1]), Convert.ToInt32(monthday1[2]))
                        : new DateTime(DateTime.Today.Year, Convert.ToInt32(monthday1[0]), Convert.ToInt32(monthday1[1]));
                }

                var prj = Repository.SingleOrDefault<Project>(x => x.ErpCode.Trim() == erpaccount && x.ProjectName.Trim() == prjname);
                if (prj==null)
//.........这里部分代码省略.........
开发者ID:bearing09,项目名称:JSPSBVendorsManage,代码行数:101,代码来源:ProjectController.cs

示例2: ImportSubContract

        /// <summary>
        /// 导入实际竣工日期
        /// </summary>
        /// <param name="sheet"></param>
        private void ImportSubContract(Sheet sheet)
        {
            var rows = sheet.GetRowEnumerator();
            rows.MoveNext();
            while (rows.MoveNext())
            {
                HSSFRow row = (HSSFRow)rows.Current;
                var cell = row.GetCell(1);
                if (cell == null) continue;
                cell.SetCellType(CellType.STRING);
                var erpaccount = cell.StringCellValue.Trim();
                if (string.IsNullOrEmpty(erpaccount)) continue;// 如果没有erp账号不导入

                cell = row.GetCell(2);
                if (cell != null)
                    cell.SetCellType(CellType.STRING);
                else continue;
                var prjname = cell.StringCellValue.Trim();
                if (string.IsNullOrEmpty(prjname)) continue; //没有工程名称 不导入

                //cell = row.GetCell(4);
                //if (cell != null)
                //    cell.SetCellType(CellType.STRING);
                //else continue;
                //var subcompanyname = cell.StringCellValue.Trim(); // 分包施工单位名称
                //if (string.IsNullOrEmpty(subcompanyname)) continue; //没有分包单位 不导入

                //double? balanceamount = null;
                //cell = row.GetCell(7);
                //if (cell != null)
                //{
                //    cell.SetCellType(CellType.NUMERIC);
                //    balanceamount = cell.NumericCellValue; //分包结算价
                //}

                //double? contractamount = null;
                //cell = row.GetCell(6);
                //if (cell != null)
                //{
                //    cell.SetCellType(CellType.NUMERIC);
                //    contractamount = cell.NumericCellValue; //分包合同价
                //}

                DateTime? startdate = null;
                DateTime? enddate = null;
                //cell = row.GetCell(4);
                //if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                //{
                //    startdate = cell.DateCellValue; //实际开工日期
                //}

                cell = row.GetCell(0);
                if (cell != null && !string.IsNullOrEmpty(cell.ToString()))
                {
                    enddate = cell.DateCellValue; //实际竣工
                }
                // 更新和保存二级施工单位信息
                var prj =
                    Repository.SingleOrDefault<Project>(x => x.ErpCode.Trim() == erpaccount && x.ProjectName.Trim() == prjname);
                if(prj ==null)
                {
                     prj = new Project
                    {
                        ErpCode = erpaccount,

                        ProjectName = prjname,
                        ProjectTypeId = GetTypeIdByErpcode(erpaccount),
                        IsOnProcessed = false,
                        IsFinished = true,
                        CreatedBy = CurrentUser.UserName,
                        CreatedOn = DateTime.Now
                    };
                     _projectService.AddDoneProject(prj, CurrentUser.UserId);
                }

                var subcontract =
                    prj.SubContracts.SingleOrDefault(x => enddate.HasValue && (x.EndDate.HasValue && x.EndDate.Value.Date.CompareTo(enddate.Value.Date)==0));

                if (subcontract==null)
                {
                    prj.SubContracts.Add(new SubContract{CreatedOn = DateTime.Now,CreateBy = User.Identity.Name,
                                                        // SubContractAmount = contractamount.HasValue ? (decimal)contractamount.Value : 0,
                                                       //  SubBalanceAmount = balanceamount.HasValue ? (decimal)balanceamount.Value :0,
                                                       //  StartDate = startdate,
                                                         EndDate = enddate,
                                                         ProjectId = prj.ProjectId,
                                                         //SubCompanyId = GetConstructCompanyId(subcompanyname)
                    });
                }
                else
                {
                   // subcontract.SubContractAmount = contractamount.HasValue ? (decimal) contractamount.Value : 0;
                   // subcontract.SubBalanceAmount = balanceamount.HasValue ? (decimal) balanceamount : 0;
                   // subcontract.StartDate = startdate;
                    subcontract.EndDate = enddate;
                }
//.........这里部分代码省略.........
开发者ID:bearing09,项目名称:JSPSBVendorsManage,代码行数:101,代码来源:ProjectController.cs


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