Exemple #1
0
        /// <summary>
        /// CopyCell
        /// </summary>
        /// <param name="oldCell"></param>
        /// <param name="newCell"></param>
        public ICell CopyCell(ICell oldCell, ICell newCell)
        {
            // Copy style from old cell and apply to new cell
            var newCellStyle = Wk.CreateCellStyle();

            newCellStyle.CloneStyleFrom(oldCell.CellStyle);;
            newCell.CellStyle = newCellStyle;

            // If there is a cell comment, copy
            if (newCell.CellComment != null)
            {
                newCell.CellComment = oldCell.CellComment;
            }

            // If there is a cell hyperlink, copy
            if (oldCell.Hyperlink != null)
            {
                newCell.Hyperlink = oldCell.Hyperlink;
            }

            // Set the cell data type
            newCell.SetCellType(oldCell.CellType);

            switch (oldCell.CellType)
            {
            case CellType.Blank:
                newCell.SetCellValue(oldCell.StringCellValue);
                break;

            case CellType.Boolean:
                newCell.SetCellValue(oldCell.BooleanCellValue);
                break;

            case CellType.Error:
                newCell.SetCellErrorValue(oldCell.ErrorCellValue);
                break;

            case CellType.Formula:
                newCell.SetCellFormula(oldCell.CellFormula);
                break;

            case CellType.Numeric:
                newCell.SetCellValue(oldCell.NumericCellValue);
                break;

            case CellType.String:
                newCell.SetCellValue(oldCell.RichStringCellValue);
                break;

            case CellType.Unknown:
                newCell.SetCellValue(oldCell.StringCellValue);
                break;
            }

            return(newCell);
        }
        void 期間編集()
        {
            if (string.IsNullOrWhiteSpace(作成年月) == true || string.IsNullOrWhiteSpace(作成締日) == true)
            {
                this.請求対象期間From = string.Empty;
                this.請求対象期間To   = string.Empty;
                return;
            }
            try
            {
                int day;
                if (int.TryParse(作成締日, out day) != true)
                {
                    day = 0;
                }

                DateTime ymd1;
                DateTime ymd2;
                bool     flg = DateTime.TryParse(string.Format("{0}/{1}", 作成年月, day), out ymd2);
                if (flg == true)
                {
                    ymd1 = ymd2.AddMonths(-1);
                    ymd1 = ymd1.AddDays(1);
                }
                else
                {
                    DateTime Wk;
                    ymd2 = DateTime.TryParse(string.Format("{0}/1", 作成年月), out Wk) ? Wk.AddMonths(1).AddDays(-1) : DateTime.Today;
                    ymd1 = ymd2.AddMonths(-1);
                    ymd1 = ymd1.AddDays(1);
                }
                if (day == 31)
                {
                    DateTime Wk;
                    ymd1 = DateTime.TryParse(string.Format("{0}/1", 作成年月), out Wk) ? Wk : DateTime.Today;
                }

                this.請求対象期間From = ymd1.ToString("yyyy/MM/dd");
                this.請求対象期間To   = ymd2.ToString("yyyy/MM/dd");
            }
            catch (Exception)
            {
            }
        }
Exemple #3
0
        /// <summary>
        /// 复制行格式并插入指定行数
        /// </summary>
        /// <param name="sheet">当前sheet</param>
        /// <param name="startRowIndex">起始行位置</param>
        /// <param name="sourceRowIndex">模板行位置</param>
        /// <param name="insertCount">插入行数</param>
        public void CopyRow(ISheet sheet, int startRowIndex, int sourceRowIndex, int insertCount)
        {
            ISheet sourceSheet     = Wk.GetSheet(Wk.GetSheetName(1));
            IRow   sourceRow       = sourceSheet.GetRow(sourceRowIndex);
            int    sourceCellCount = sourceRow.Cells.Count;

            //1. 批量移动行,清空插入区域
            sheet.ShiftRows(startRowIndex,    //开始行
                            sheet.LastRowNum, //结束行
                            insertCount,      //插入行总数
                            true,             //是否复制行高
                            false             //是否重置行高
                            );

            int startMergeCell = -1; //记录每行的合并单元格起始位置

            for (int i = startRowIndex; i < startRowIndex + insertCount; i++)
            {
                IRow  targetRow = null;
                ICell oldCell   = null;
                ICell newCell   = null;

                targetRow        = sheet.CreateRow(i);
                targetRow.Height = sourceRow.Height;//复制行高

                for (int m = sourceRow.FirstCellNum; m < sourceRow.LastCellNum; m++)
                {
                    oldCell = sourceRow.GetCell(m);
                    newCell = targetRow.CreateCell(m);

                    // If the old cell is null jump to next cell
                    if (oldCell == null)
                    {
                        newCell = null;
                        continue;
                    }

                    // Set the cell data value
                    CopyCell(oldCell, newCell);

                    startMergeCell = MergeCell(sheet, sourceCellCount, startMergeCell, i, oldCell, m);
                }
            }
        }
Exemple #4
0
        private void InitializeWorkbook()
        {
            if (!FileName.IsNullOrEmpty())
            {
                Wk = WorkbookFactory.Create(FileName);

                FontOne                    = new HSSFFont(NPOI.HSSF.Util.HSSFColor.Blue.Index, new NPOI.HSSF.Record.FontRecord());
                FontOne.FontName           = "宋体";
                FontOne.FontHeightInPoints = 11;

                CellStyleOne            = Wk.CreateCellStyle();
                CellStyleOne.DataFormat = HSSFDataFormat.GetBuiltinFormat("0");

                CellStyleTwo                = Wk.CreateCellStyle();
                CellStyleTwo.DataFormat     = HSSFDataFormat.GetBuiltinFormat("0.00%");
                CellStyleTwo.TopBorderColor = NPOI.HSSF.Util.HSSFColor.Blue.Index;
                // CellStyleTwo.SetFont(FontOne);
            }
        }
Exemple #5
0
        private static void ByCombo()
        {
            if (Player.Instance.IsKayn())
            {
                // Q usage
                if (Qk.IsBackRange(Orbwalker.ActiveModes.Combo) && !Kayn.IsAboutToTransform())
                {
                    var target = Qk.GetTarget();
                    if (target != null)
                    {
                        var prediction = Qk.GetPrediction(target);

                        switch (prediction.HitChance)
                        {
                        case HitChance.High:
                        case HitChance.Immobile:

                            // Regular Q cast
                            if (Qk.Cast(prediction.CastPosition))
                            {
                                return;
                            }
                            break;

                        case HitChance.Collision:

                            // Special case for colliding enemies
                            var colliding = prediction.CollisionObjects.OrderBy(o => o.Distance(Kayn, true)).ToList();
                            if (colliding.Count > 0)
                            {
                                // First colliding target is < 100 units away from our main target
                                if (colliding[0].IsInRange(target, 100))
                                {
                                    if (Qk.Cast(prediction.CastPosition))
                                    {
                                        return;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                if (Wk.IsBackRange(Orbwalker.ActiveModes.Combo) && !Kayn.IsAboutToTransform())
                {
                    var target = Wk.GetTarget();
                    if (target != null)
                    {
                        var prediction = Wk.GetPrediction(target);

                        switch (prediction.HitChance)
                        {
                        case HitChance.High:
                        case HitChance.Immobile:

                            // Regular W cast
                            if (Wk.Cast(prediction.CastPosition))
                            {
                                return;
                            }
                            break;

                        case HitChance.Collision:

                            // Special case for colliding enemies
                            var colliding = prediction.CollisionObjects.OrderBy(o => o.Distance(Kayn, true)).ToList();
                            if (colliding.Count > 0)
                            {
                                // First colliding target is < 100 units away from our main target
                                if (colliding[0].IsInRange(target, 100))
                                {
                                    if (Wk.Cast(prediction.CastPosition))
                                    {
                                        return;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }

                if (R.IsBackRange(Orbwalker.ActiveModes.Combo))
                {
                    var target = R.GetTarget();
                    if (target != null && target.HealthPercent < Menus.Combo["Rs"].Cast <Slider>().CurrentValue)
                    {
                        if (!target.IsInRange(Kayn, R.Range) && R.IsReady())
                        {
                            return;
                        }
                        {
                            R.Cast(target);
                        }
                    }
                }
            }
        }