コード例 #1
0
        private void SaveExcel(List <FileProperty> flist)
        {
            saveFileDialog1.OverwritePrompt    = true;
            saveFileDialog1.AddExtension       = true;
            saveFileDialog1.DefaultExt         = ".xls";
            saveFileDialog1.AutoUpgradeEnabled = true;
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                toolStripStatusLabel1.Text = "正在生成Excel文件";
                string path = saveFileDialog1.FileName;
                NPOI.HSSF.UserModel.HSSFWorkbook workBook = new NPOI.HSSF.UserModel.HSSFWorkbook();
                NPOI.SS.UserModel.Sheet          sheet    = workBook.CreateSheet("Sheet1");
                NPOI.SS.UserModel.Row            row1     = sheet.CreateRow(0);
                row1.CreateCell(0).SetCellValue("Title");
                row1.CreateCell(1).SetCellValue("FilePath");
                row1.CreateCell(2).SetCellValue("Description");
                row1.CreateCell(3).SetCellValue("Tags");
                row1.CreateCell(4).SetCellValue("Price");
                row1.CreateCell(5).SetCellValue("CateId");
                row1.CreateCell(6).SetCellValue("Test");

                for (int i = 0; i < flist.Count; i++)
                {
                    NPOI.SS.UserModel.Row r = sheet.CreateRow(i + 1);
                    r.CreateCell(0).SetCellValue(flist[i].Name);
                    r.CreateCell(1).SetCellValue(flist[i].Path);
                }

                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    workBook.Write(fs);
                }
                toolStripStatusLabel1.Text = "生成Excel成功";
            }
        }
コード例 #2
0
        public FileResult AgreementDetailListExportExcel(long accountId, int enumOrderTypeId, DateTime?startDate, DateTime?endDate)
        {
            var queryModel = new AccountQuery()
            {
                StartDate = startDate,
                EndDate   = endDate.HasValue ? endDate.Value.AddDays(1) : endDate,
                AccountId = accountId,
                PageSize  = int.MaxValue,
                PageNo    = 1
            };


            ObsoletePageModel <AccountMetaModel> pageModelMetaInfo = _iAccountService.GetAccountMeta(queryModel);
            var mode = pageModelMetaInfo.Models.ToList().Select(e => new AccountMetaModel
            {
                AccountId = e.Id,
                Id        = e.Id,
                EndDate   = e.EndDate,
                StartDate = e.StartDate,
                MetaKey   = e.MetaKey,
                MetaValue = e.MetaValue,
                DateRange = e.StartDate.ToString("yyyy-MM-dd") + " 至 " + e.EndDate.ToString("yyyy-MM-dd")
            }).ToList();

            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.Sheet sheet1 = book.CreateSheet("Sheet1");
            //获取list数据

            //给sheet1添加第一行的头部标题

            NPOI.SS.UserModel.Row row1 = sheet1.CreateRow(0);

            row1.CreateCell(0).SetCellValue("类型");
            row1.CreateCell(1).SetCellValue("营销类型");
            row1.CreateCell(2).SetCellValue("费用");
            row1.CreateCell(3).SetCellValue("服务周期");
            sheet1.SetColumnWidth(0, 550 * 5);
            sheet1.SetColumnWidth(1, 550 * 20);
            sheet1.SetColumnWidth(2, 550 * 8);
            sheet1.SetColumnWidth(3, 550 * 15);

            //将数据逐步写入sheet1各个行
            for (int i = 0; i < mode.Count(); i++)
            {
                NPOI.SS.UserModel.Row rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue("营销服务费");
                rowtemp.CreateCell(1).SetCellValue(mode[i].MetaKey);
                rowtemp.CreateCell(2).SetCellValue(mode[i].MetaValue);
                rowtemp.CreateCell(3).SetCellValue(mode[i].DateRange);
            }

            // 写入到客户端
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", "结算详情-营销服务费列表.xls"));
        }
コード例 #3
0
ファイル: VwXls.cs プロジェクト: windrobin/kumpro
        private void ActivateSheet(NPOI.SS.UserModel.Sheet sheet)
        {
            DataTable dt    = new DataTable(sheet.SheetName);
            int       maxCx = 0;
            int       cy    = sheet.PhysicalNumberOfRows;

            for (int y = 0; y < cy; y++)
            {
                NPOI.SS.UserModel.Row row = sheet.GetRow(y);
                if (row != null)
                {
                    int cx = row.PhysicalNumberOfCells;
                    maxCx = Math.Max(maxCx, row.FirstCellNum + cx);
                }
            }
            int maxCy = sheet.FirstRowNum + cy;

            for (int x = 0; x < maxCx; x++)
            {
                DataColumn col = dt.Columns.Add("C" + (1 + x), typeof(String));
            }
            for (int vy = 0; vy < maxCy; vy++)
            {
                DataRow dr = dt.NewRow();
                if (vy >= sheet.FirstRowNum)
                {
                    int y = vy - sheet.FirstRowNum;
                    NPOI.SS.UserModel.Row row = sheet.GetRow(y);
                    for (int vx = 0; vx < maxCx; vx++)
                    {
                        dr[vx] = "";
                        if (row != null)
                        {
                            if (vx >= row.FirstCellNum)
                            {
                                int x = vx - row.FirstCellNum;
                                NPOI.SS.UserModel.Cell cell = row.GetCell(x);
                                dr[vx] = (cell != null) ? cell.ToString() : "";
                            }
                        }
                    }
                }
                dt.Rows.Add(dr);
            }

            gv.DataSource = dt;

            foreach (DataGridViewColumn col in gv.Columns)
            {
                col.ReadOnly = true;
            }

            gv.AutoResizeColumns();
            gv.AutoResizeRows();
        }
コード例 #4
0
        private NPOI.SS.UserModel.Row GetRow(NPOI.SS.UserModel.Sheet sheet, int line)
        {
            NPOI.SS.UserModel.Row row = sheet.GetRow(line);

            if (row == null)
            {
                row = sheet.CreateRow(line);
            }

            return(row);
        }
コード例 #5
0
 /// <summary>
 /// Gets the row height in points.
 /// </summary>
 /// <param name="sheet">The sheet.</param>
 /// <param name="rowNum">The row num.</param>
 /// <returns></returns>
 private float GetRowHeightInPoints(NPOI.SS.UserModel.Sheet sheet, int rowNum)
 {
     NPOI.SS.UserModel.Row row = sheet.GetRow(rowNum);
     if (row == null)
     {
         return(sheet.DefaultRowHeightInPoints);
     }
     else
     {
         return(row.HeightInPoints);
     }
 }
コード例 #6
0
        private NPOI.SS.UserModel.Cell GetCell(NPOI.SS.UserModel.Sheet sheet, int line, int col)
        {
            NPOI.SS.UserModel.Row row = GetRow(sheet, line);

            NPOI.SS.UserModel.Cell cell = row.GetCell(col);

            if (cell == null)
            {
                cell = row.CreateCell(col);
            }

            return(cell);
        }
コード例 #7
0
ファイル: HSSFRegionUtil.cs プロジェクト: thinhmascot/NPOI
        //[Obsolete]
        //public static void SetTopBorderColor(short color, Region region, HSSFSheet sheet,
        //        HSSFWorkbook workbook)
        //{
        //    SetTopBorderColor(color, toCRA(region), sheet, workbook);
        //}
        /// <summary>
        /// Sets the topBorderColor attribute of the HSSFRegionUtil object
        /// </summary>
        /// <param name="color">The color of the border</param>
        /// <param name="region">The region that should have the border</param>
        /// <param name="sheet">The sheet that the region is on.</param>
        /// <param name="workbook">The workbook that the region is on.</param>
        public static void SetTopBorderColor(int color, CellRangeAddress region, HSSFSheet sheet,
                                             HSSFWorkbook workbook)
        {
            int colStart           = region.FirstColumn;
            int colEnd             = region.LastColumn;
            int rowIndex           = region.FirstRow;
            CellPropertySetter cps = new CellPropertySetter(workbook, HSSFCellUtil.TOP_BORDER_COLOR, color);

            NPOI.SS.UserModel.Row row = HSSFCellUtil.GetRow(rowIndex, sheet);
            for (int i = colStart; i <= colEnd; i++)
            {
                cps.SetProperty(row, i);
            }
        }
コード例 #8
0
ファイル: HSSFRegionUtil.cs プロジェクト: thinhmascot/NPOI
        //[Obsolete]
        //public static void SetBorderBottom(NPOI.SS.UserModel.CellBorderType border, Region region, HSSFSheet sheet,
        //        HSSFWorkbook workbook)
        //{
        //    SetBorderBottom(border, toCRA(region), sheet, workbook);
        //}
        /// <summary>
        /// Sets the borderBottom attribute of the HSSFRegionUtil object
        /// </summary>
        /// <param name="border">The new border</param>
        /// <param name="region">The region that should have the border</param>
        /// <param name="sheet">The sheet that the region is on.</param>
        /// <param name="workbook">The workbook that the region is on.</param>
        public static void SetBorderBottom(NPOI.SS.UserModel.CellBorderType border, CellRangeAddress region, HSSFSheet sheet,
                                           HSSFWorkbook workbook)
        {
            int colStart           = region.FirstColumn;
            int colEnd             = region.LastColumn;
            int rowIndex           = region.LastRow;
            CellPropertySetter cps = new CellPropertySetter(workbook, HSSFCellUtil.BORDER_BOTTOM, (int)border);

            NPOI.SS.UserModel.Row row = HSSFCellUtil.GetRow(rowIndex, sheet);
            for (int i = colStart; i <= colEnd; i++)
            {
                cps.SetProperty(row, i);
            }
        }
コード例 #9
0
ファイル: TestDate.cs プロジェクト: thinhmascot/NPOI
        public void SetUp()
        {
            HSSFWorkbook wb = new HSSFWorkbook();

            NPOI.SS.UserModel.Sheet sheet = wb.CreateSheet("new sheet");
            NPOI.SS.UserModel.Row   row1  = sheet.CreateRow(0);

            this.cell11 = row1.CreateCell(0);
            this.cell12 = row1.CreateCell(1);
            this.cell13 = row1.CreateCell(2);
            this.cell14 = row1.CreateCell(3);
            this.cell15 = row1.CreateCell(4);
            this.cell16 = row1.CreateCell(5);

            this.evaluator = new HSSFFormulaEvaluator(sheet, wb);
            //this.evaluator.SetCurrentRow(row1);
        }
コード例 #10
0
        public FileResult ExportExcel(int status, string shopName)
        {
            var queryModel = new AccountQuery()
            {
                Status   = (Model.AccountInfo.AccountStatus?)status,
                ShopName = shopName,
                PageSize = int.MaxValue,
                PageNo   = 1
            };

            ObsoletePageModel <AccountInfo> accounts = _iAccountService.GetAccounts(queryModel);
            IList <AccountModel>            models   = new List <AccountModel>();

            foreach (var item in accounts.Models.ToArray())
            {
                AccountModel model = new AccountModel();
                model.Id                      = item.Id;
                model.ShopId                  = item.ShopId;
                model.ShopName                = item.ShopName;
                model.AccountDate             = item.AccountDate.ToString();
                model.StartDate               = item.StartDate;
                model.EndDate                 = item.EndDate;
                model.Status                  = (int)item.Status;
                model.ProductActualPaidAmount = item.ProductActualPaidAmount;
                model.FreightAmount           = item.FreightAmount;
                model.CommissionAmount        = item.CommissionAmount;
                model.RefundAmount            = item.RefundAmount;
                model.RefundCommissionAmount  = item.RefundCommissionAmount;
                model.BrokerageAmount         = item.Brokerage;
                model.ReturnBrokerageAmount   = item.ReturnBrokerage;
                model.AdvancePaymentAmount    = item.AdvancePaymentAmount;
                model.PeriodSettlement        = item.PeriodSettlement;
                model.Remark                  = item.Remark;
                model.TimeSlot                = string.Format("{0} 至 {1}", model.StartDate.Date.ToString("yyyy-MM-dd"), model.EndDate.Date.ToString("yyyy-MM-dd"));
                models.Add(model);
            }

            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.Sheet sheet1 = book.CreateSheet("Sheet1");
            //获取list数据

            //给sheet1添加第一行的头部标题

            NPOI.SS.UserModel.Row row1 = sheet1.CreateRow(0);
            row1.CreateCell(0).SetCellValue("诊所名称");
            row1.CreateCell(1).SetCellValue("时间段");
            row1.CreateCell(2).SetCellValue("诊疗项目实付总额");
            row1.CreateCell(3).SetCellValue("运费");
            row1.CreateCell(4).SetCellValue("佣金");
            row1.CreateCell(5).SetCellValue("退款金额");
            row1.CreateCell(6).SetCellValue("退还佣金");
            row1.CreateCell(7).SetCellValue("分佣佣金");
            row1.CreateCell(8).SetCellValue("退还分佣佣金");
            row1.CreateCell(9).SetCellValue("营销费用总额");
            row1.CreateCell(10).SetCellValue("本期应结");
            row1.CreateCell(11).SetCellValue("出账日期");
            //将数据逐步写入sheet1各个行
            for (int i = 0; i < models.Count; i++)
            {
                NPOI.SS.UserModel.Row rowtemp = sheet1.CreateRow(i + 1);
                rowtemp.CreateCell(0).SetCellValue(models[i].ShopName);
                rowtemp.CreateCell(1).SetCellValue(models[i].TimeSlot);
                rowtemp.CreateCell(2).SetCellValue(models[i].ProductActualPaidAmount.ToString());
                rowtemp.CreateCell(3).SetCellValue(models[i].FreightAmount.ToString());
                rowtemp.CreateCell(4).SetCellValue(models[i].CommissionAmount.ToString());
                rowtemp.CreateCell(5).SetCellValue(models[i].RefundAmount.ToString());
                rowtemp.CreateCell(6).SetCellValue(models[i].RefundCommissionAmount.ToString());
                rowtemp.CreateCell(7).SetCellValue(models[i].BrokerageAmount.ToString());
                rowtemp.CreateCell(8).SetCellValue(models[i].ReturnBrokerageAmount.ToString());
                rowtemp.CreateCell(9).SetCellValue(models[i].AdvancePaymentAmount.ToString());
                rowtemp.CreateCell(10).SetCellValue(models[i].PeriodSettlement.ToString());
                rowtemp.CreateCell(11).SetCellValue(models[i].AccountDate.ToString());
            }

            // 写入到客户端
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", "结算管理.xls"));
        }
コード例 #11
0
        public FileResult DetailListExportExcel(long accountId, int enumOrderTypeId, DateTime?startDate, DateTime?endDate)
        {
            var queryModel = new AccountQuery()
            {
                StartDate     = startDate,
                EndDate       = endDate.HasValue ? endDate.Value.AddDays(1) : endDate,
                AccountId     = accountId,
                PageSize      = int.MaxValue,
                EnumOrderType = (AccountDetailInfo.EnumOrderType)enumOrderTypeId,
                PageNo        = 1
            };
            var accountDetails = _iAccountService.GetAccountDetails(queryModel);

            var accountDetailsModel = (from p in accountDetails.Models.ToList()
                                       select new
            {
                p.Id,
                p.OrderType,
                OrderTypeDescription = p.OrderType.ToDescription(),
                p.OrderId,
                p.ProductActualPaidAmount,
                p.FreightAmount,
                p.CommissionAmount,
                p.RefundCommisAmount,
                p.RefundTotalAmount,
                Date = p.Date.ToString(),
                OrderDate = p.OrderDate.ToString(),
                p.OrderRefundsDates
            }).ToList();

            //创建Excel文件的对象
            NPOI.HSSF.UserModel.HSSFWorkbook book = new NPOI.HSSF.UserModel.HSSFWorkbook();
            //添加一个sheet
            NPOI.SS.UserModel.Sheet sheet1 = book.CreateSheet("Sheet1");
            //获取list数据

            //给sheet1添加第一行的头部标题
            string titleFlag = string.Empty;

            NPOI.SS.UserModel.Row row1 = sheet1.CreateRow(0);
            if (enumOrderTypeId == 1)
            {
                titleFlag = "预约单列表";
                row1.CreateCell(0).SetCellValue("类型");
                row1.CreateCell(1).SetCellValue("预约单编号");
                row1.CreateCell(2).SetCellValue("诊疗项目实付金额");
                row1.CreateCell(3).SetCellValue("运费");
                row1.CreateCell(4).SetCellValue("佣金");
                row1.CreateCell(5).SetCellValue("下单日期");
                row1.CreateCell(6).SetCellValue("成交日期");
                sheet1.SetColumnWidth(0, 550 * 5);
                sheet1.SetColumnWidth(1, 550 * 20);
                sheet1.SetColumnWidth(2, 550 * 8);
                sheet1.SetColumnWidth(3, 550 * 5);
                sheet1.SetColumnWidth(4, 550 * 5);
                sheet1.SetColumnWidth(5, 550 * 15);
                sheet1.SetColumnWidth(6, 550 * 15);
            }
            else if (enumOrderTypeId == 0)
            {
                titleFlag = "退单列表";
                row1.CreateCell(0).SetCellValue("类型");
                row1.CreateCell(1).SetCellValue("预约单编号");
                row1.CreateCell(2).SetCellValue("诊疗项目实付金额");
                row1.CreateCell(3).SetCellValue("运费");
                row1.CreateCell(4).SetCellValue("退款金额");
                row1.CreateCell(5).SetCellValue("退还佣金");
                row1.CreateCell(6).SetCellValue("退单日期");
                sheet1.SetColumnWidth(0, 550 * 5);
                sheet1.SetColumnWidth(1, 550 * 20);
                sheet1.SetColumnWidth(2, 550 * 8);
                sheet1.SetColumnWidth(3, 550 * 5);
                sheet1.SetColumnWidth(4, 550 * 8);
                sheet1.SetColumnWidth(5, 550 * 5);
                sheet1.SetColumnWidth(6, 550 * 15);
            }

            //将数据逐步写入sheet1各个行
            for (int i = 0; i < accountDetailsModel.Count(); i++)
            {
                NPOI.SS.UserModel.Row rowtemp = sheet1.CreateRow(i + 1);
                if (enumOrderTypeId == 1)
                {
                    rowtemp.CreateCell(0).SetCellValue(titleFlag);
                    rowtemp.CreateCell(1).SetCellValue(accountDetailsModel[i].OrderId.ToString());
                    rowtemp.CreateCell(2).SetCellValue(accountDetailsModel[i].ProductActualPaidAmount.ToString());
                    rowtemp.CreateCell(3).SetCellValue(accountDetailsModel[i].FreightAmount.ToString());
                    rowtemp.CreateCell(4).SetCellValue(accountDetailsModel[i].CommissionAmount.ToString());
                    rowtemp.CreateCell(5).SetCellValue(accountDetailsModel[i].OrderDate.ToString());
                    rowtemp.CreateCell(6).SetCellValue(accountDetailsModel[i].Date.ToString());
                }
                else if (enumOrderTypeId == 0)
                {
                    rowtemp.CreateCell(0).SetCellValue(titleFlag);
                    rowtemp.CreateCell(1).SetCellValue(accountDetailsModel[i].OrderId.ToString());
                    rowtemp.CreateCell(2).SetCellValue(accountDetailsModel[i].ProductActualPaidAmount.ToString());
                    rowtemp.CreateCell(3).SetCellValue(accountDetailsModel[i].FreightAmount.ToString());
                    rowtemp.CreateCell(4).SetCellValue(accountDetailsModel[i].RefundTotalAmount.ToString());
                    rowtemp.CreateCell(5).SetCellValue(accountDetailsModel[i].RefundCommisAmount.ToString());
                    rowtemp.CreateCell(6).SetCellValue(accountDetailsModel[i].OrderRefundsDates.ToString());
                }
            }

            // 写入到客户端
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            book.Write(ms);
            ms.Seek(0, SeekOrigin.Begin);
            return(File(ms, "application/vnd.ms-excel", string.Format("结算详情-{0}.xls", titleFlag)));
        }
コード例 #12
0
ファイル: HSSFRegionUtil.cs プロジェクト: thinhmascot/NPOI
 public void SetProperty(NPOI.SS.UserModel.Row row, int column)
 {
     NPOI.SS.UserModel.Cell cell = HSSFCellUtil.GetCell(row, column);
     HSSFCellUtil.SetCellStyleProperty(cell, _workbook, _propertyName, _propertyValue);
 }
コード例 #13
0
        public void CreateFile(Model.Campeonatos.Campeonato campeonato, Model.Boloes.Bolao bolao)
        {
            if (System.IO.File.Exists(_fileName))
            {
                System.IO.File.Delete(_fileName);
            }



            //FileStream stream = new FileStream(_fileName, FileMode.Create, FileAccess.Write);
            //NPOI.HSSF.UserModel.HSSFWorkbook wb = new NPOI.HSSF.UserModel.HSSFWorkbook(stream);

            NPOI.SS.UserModel.Workbook wb = new NPOI.HSSF.UserModel.HSSFWorkbook();


            NPOI.SS.UserModel.Sheet sheetJogos = wb.CreateSheet("Jogos-Grupo");

            Business.Campeonatos.Support.Campeonato             camp  = new Business.Campeonatos.Support.Campeonato(_currentLogin, campeonato);
            IList <Framework.DataServices.Model.EntityBaseData> jogos = camp.LoadJogos(0, null, null, DateTime.MinValue, DateTime.MinValue, null);


            IList <Framework.DataServices.Model.EntityBaseData> grupos = camp.LoadGrupos();

            int count = 0;
            int line  = 0;

            foreach (Model.Campeonatos.Grupo grupo in grupos)
            {
                if (!string.IsNullOrEmpty(grupo.Nome.Trim()))
                {
                    NPOI.SS.UserModel.Row  row       = sheetJogos.CreateRow(count++);
                    NPOI.SS.UserModel.Cell grupoCell = row.CreateCell(0);
                    grupoCell.SetCellValue("Grupo " + grupo.Nome);


                    line = 0;
                    row  = sheetJogos.CreateRow(count++);
                    row.CreateCell(line++).SetCellValue("Jogo");
                    row.CreateCell(line++).SetCellValue("Data/Hora");
                    row.CreateCell(line++).SetCellValue("Local");
                    row.CreateCell(line++).SetCellValue("Time");
                    row.CreateCell(line++).SetCellValue("Gols");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("x");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("");
                    row.CreateCell(line++).SetCellValue("Gols");
                    row.CreateCell(line++).SetCellValue("Time");
                    row.CreateCell(line++).SetCellValue("");


                    foreach (Model.Campeonatos.Jogo jogo in jogos)
                    {
                        if (string.Compare(jogo.Grupo.Nome, grupo.Nome, true) == 0)
                        {
                            line = 0;
                            row  = sheetJogos.CreateRow(count++);
                            row.CreateCell(line++).SetCellValue(jogo.JogoLabel);
                            row.CreateCell(line++).SetCellValue(jogo.DataJogo.ToString("dd/MM/yy HH:mm"));
                            row.CreateCell(line++).SetCellValue(jogo.Estadio.ToString());
                            row.CreateCell(line++).SetCellValue(jogo.Time1.Nome);
                            if (jogo.PartidaValida)
                            {
                                row.CreateCell(line++).SetCellValue(jogo.GolsTime1);
                            }
                            else
                            {
                                row.CreateCell(line++).SetCellValue("");
                            }
                            row.CreateCell(line++).SetCellValue("");

                            row.CreateCell(line++).SetCellValue("");
                            row.CreateCell(line++).SetCellValue("x");

                            row.CreateCell(line++).SetCellValue("");
                            row.CreateCell(line++).SetCellValue("");

                            if (jogo.PartidaValida)
                            {
                                row.CreateCell(line++).SetCellValue(jogo.GolsTime2);
                            }
                            else
                            {
                                row.CreateCell(line++).SetCellValue("");
                            }
                            row.CreateCell(line++).SetCellValue(jogo.Time2.Nome);
                            row.CreateCell(line++).SetCellValue("");
                        }
                    }

                    sheetJogos.CreateRow(count++);
                }
            }


            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Oitavas de Final", ref count, jogos);
            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Quartas de Final", ref count, jogos);
            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Semi Finais", ref count, jogos);
            sheetJogos.CreateRow(count++);
            CreateFase(sheetJogos, "Final", ref count, jogos);


            Business.Boloes.Support.Bolao bolaoBO = new Business.Boloes.Support.Bolao(_currentLogin, bolao.Nome);

            IList <Framework.DataServices.Model.EntityBaseData> users = bolaoBO.LoadMembros();

            foreach (Framework.Security.Model.UserData user in users)
            {
                CreateUser(wb, user.UserName, bolaoBO);
            }



            wb.Write(new FileStream(_fileName, FileMode.Create));
        }
コード例 #14
0
        private void CreateFase(NPOI.SS.UserModel.Sheet sheet, string fase, ref int count, IList <Framework.DataServices.Model.EntityBaseData> list)
        {
            NPOI.SS.UserModel.Row  rowJogo       = sheet.CreateRow(count++);
            NPOI.SS.UserModel.Cell grupoCellJogo = rowJogo.CreateCell(0);
            grupoCellJogo.SetCellValue(fase);

            int line = 0;

            rowJogo = sheet.CreateRow(count++);
            rowJogo.CreateCell(line++).SetCellValue("Jogo");
            rowJogo.CreateCell(line++).SetCellValue("Data/Hora");
            rowJogo.CreateCell(line++).SetCellValue("Local");
            rowJogo.CreateCell(line++).SetCellValue("Time");
            rowJogo.CreateCell(line++).SetCellValue("Gols");
            rowJogo.CreateCell(line++).SetCellValue("Penal");

            rowJogo.CreateCell(line++).SetCellValue("");
            rowJogo.CreateCell(line++).SetCellValue("x");
            rowJogo.CreateCell(line++).SetCellValue("");

            rowJogo.CreateCell(line++).SetCellValue("Penal");
            rowJogo.CreateCell(line++).SetCellValue("Gols");
            rowJogo.CreateCell(line++).SetCellValue("Time");
            rowJogo.CreateCell(line++).SetCellValue("");


            foreach (Model.Campeonatos.Jogo jogo in list)
            {
                if (string.Compare(jogo.Fase.Nome, fase, true) == 0)
                {
                    line    = 0;
                    rowJogo = sheet.CreateRow(count++);
                    rowJogo.CreateCell(line++).SetCellValue(jogo.JogoLabel);
                    rowJogo.CreateCell(line++).SetCellValue(jogo.DataJogo.ToString("dd/MM/yy HH:mm"));
                    rowJogo.CreateCell(line++).SetCellValue(jogo.Estadio.ToString());
                    rowJogo.CreateCell(line++).SetCellValue(jogo.Time1.Nome);
                    if (jogo.PartidaValida)
                    {
                        rowJogo.CreateCell(line++).SetCellValue(jogo.GolsTime1);
                    }
                    else
                    {
                        rowJogo.CreateCell(line++).SetCellValue("");
                    }


                    if (jogo.PartidaValida && jogo.GolsTime1 == jogo.GolsTime2)
                    {
                        rowJogo.CreateCell(line++).SetCellValue(jogo.PenaltisTime1);
                    }
                    else
                    {
                        rowJogo.CreateCell(line++).SetCellValue("");
                    }

                    rowJogo.CreateCell(line++).SetCellValue("");

                    rowJogo.CreateCell(line++).SetCellValue("x");

                    rowJogo.CreateCell(line++).SetCellValue("");

                    if (jogo.PartidaValida && jogo.GolsTime1 == jogo.GolsTime2)
                    {
                        rowJogo.CreateCell(line++).SetCellValue(jogo.PenaltisTime2);
                    }
                    else
                    {
                        rowJogo.CreateCell(line++).SetCellValue("");
                    }

                    if (jogo.PartidaValida)
                    {
                        rowJogo.CreateCell(line++).SetCellValue(jogo.GolsTime2);
                    }
                    else
                    {
                        rowJogo.CreateCell(line++).SetCellValue("");
                    }
                    rowJogo.CreateCell(line++).SetCellValue(jogo.Time2.Nome);
                    rowJogo.CreateCell(line++).SetCellValue("");


                    NPOI.SS.UserModel.Row rowFase = sheet.CreateRow(count++);
                    rowFase.CreateCell(3).SetCellValue(jogo.DescricaoTime1);



                    rowFase.CreateCell(11).SetCellValue(jogo.DescricaoTime2);
                }
            }
        }