예제 #1
0
파일: ExcelBase.cs 프로젝트: secondii/Yutai
        public void SetBordersEdge(Range range_0, BordersEdge bordersEdge_0, BordersLineStyle bordersLineStyle_0,
                                   BordersWeight bordersWeight_0)
        {
            range_0.Select();
            Border borders = null;

            switch (bordersEdge_0)
            {
            case BordersEdge.xlLineStyleNone:
            {
                range_0.Borders[XlBordersIndex.xlDiagonalDown].LineStyle     = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlDiagonalUp].LineStyle       = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlEdgeLeft].LineStyle         = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlEdgeTop].LineStyle          = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlEdgeBottom].LineStyle       = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlEdgeRight].LineStyle        = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlInsideVertical].LineStyle   = XlLineStyle.xlLineStyleNone;
                range_0.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlLineStyleNone;
                break;
            }

            case BordersEdge.xlLeft:
            {
                borders = range_0.Borders[XlBordersIndex.xlEdgeLeft];
                break;
            }

            case BordersEdge.xlRight:
            {
                borders = range_0.Borders[XlBordersIndex.xlEdgeRight];
                break;
            }

            case BordersEdge.xlTop:
            {
                borders = range_0.Borders[XlBordersIndex.xlEdgeTop];
                break;
            }

            case BordersEdge.xlBottom:
            {
                borders = range_0.Borders[XlBordersIndex.xlEdgeBottom];
                break;
            }

            case BordersEdge.xlDiagonalDown:
            {
                borders = range_0.Borders[XlBordersIndex.xlDiagonalDown];
                break;
            }

            case BordersEdge.xlDiagonalUp:
            {
                borders = range_0.Borders[XlBordersIndex.xlDiagonalUp];
                break;
            }

            case BordersEdge.xlInsideHorizontal:
            {
                borders = range_0.Borders[XlBordersIndex.xlInsideHorizontal];
                break;
            }

            case BordersEdge.xlInsideVertical:
            {
                borders = range_0.Borders[XlBordersIndex.xlInsideVertical];
                break;
            }
            }
            if (borders != null)
            {
                XlLineStyle xlLineStyle = XlLineStyle.xlContinuous;
                switch (bordersLineStyle_0)
                {
                case BordersLineStyle.xlContinuous:
                {
                    xlLineStyle = XlLineStyle.xlContinuous;
                    break;
                }

                case BordersLineStyle.xlDash:
                {
                    xlLineStyle = XlLineStyle.xlDash;
                    break;
                }

                case BordersLineStyle.xlDashDot:
                {
                    xlLineStyle = XlLineStyle.xlDashDot;
                    break;
                }

                case BordersLineStyle.xlDashDotDot:
                {
                    xlLineStyle = XlLineStyle.xlDashDotDot;
                    break;
                }

                case BordersLineStyle.xlDot:
                {
                    xlLineStyle = XlLineStyle.xlDot;
                    break;
                }

                case BordersLineStyle.xlDouble:
                {
                    xlLineStyle = XlLineStyle.xlDouble;
                    break;
                }

                case BordersLineStyle.xlLineStyleNone:
                {
                    xlLineStyle = XlLineStyle.xlLineStyleNone;
                    break;
                }

                case BordersLineStyle.xlSlantDashDot:
                {
                    xlLineStyle = XlLineStyle.xlSlantDashDot;
                    break;
                }
                }
                try
                {
                    borders.LineStyle = xlLineStyle;
                }
                catch
                {
                }
                XlBorderWeight xlBorderWeight = XlBorderWeight.xlThin;
                switch (bordersWeight_0)
                {
                case BordersWeight.xlHairline:
                {
                    xlBorderWeight = XlBorderWeight.xlHairline;
                    break;
                }

                case BordersWeight.xlMedium:
                {
                    xlBorderWeight = XlBorderWeight.xlMedium;
                    break;
                }

                case BordersWeight.xlThick:
                {
                    xlBorderWeight = XlBorderWeight.xlThick;
                    break;
                }

                case BordersWeight.xlThin:
                {
                    xlBorderWeight = XlBorderWeight.xlThin;
                    break;
                }
                }
                borders.Weight = xlBorderWeight;
            }
        }
예제 #2
0
파일: ExcelBase.cs 프로젝트: secondii/Yutai
 public void SetBordersEdge(Range range_0, BordersEdge bordersEdge_0)
 {
     this.SetBordersEdge(range_0, bordersEdge_0, BordersLineStyle.xlContinuous, BordersWeight.xlThin);
 }
예제 #3
0
 /// <summary>
 /// 用连续的普通粗细的线设置指定范围内的边界
 /// </summary>
 /// <param name="p_Range">单元格</param>
 /// <param name="p_BordersEdge">枚举</param>
 protected void SetRangeBorders(Range p_Range, BordersEdge p_BordersEdge)
 {
     SetBordersEdge(p_Range, p_BordersEdge, BordersLineStyle.xlContinuous, BordersWeight.xlThin);
 }
예제 #4
0
        /// <summary>
        /// SetBordersEdge 设置指定范围边框(左、顶、右、底、往右下对角线、往右上对角线、内部水平线、内部垂直线、无线)线,并可指定线条的样式(无、虚线、点线等)及线粗细
        /// </summary>
        /// <param name="p_Range">单元格</param>
        /// <param name="p_BordersEdge">边框枚举</param>
        /// <param name="p_BordersLineStyle">边框样式</param>
        /// <param name="p_BordersWeight">线条宽度</param>
        protected void SetBordersEdge(Range p_Range, BordersEdge p_BordersEdge, BordersLineStyle p_BordersLineStyle, BordersWeight p_BordersWeight)
        {
            p_Range.Select();

            Border border = null;

            switch (p_BordersEdge)
            {
            //左右顶底的线
            case BordersEdge.xlLeft:
                border = p_Range.Borders[XlBordersIndex.xlEdgeLeft];
                break;

            case BordersEdge.xlRight:
                border = p_Range.Borders[XlBordersIndex.xlEdgeRight];
                break;

            case BordersEdge.xlTop:
                border = p_Range.Borders[XlBordersIndex.xlEdgeTop];
                break;

            case BordersEdge.xlBottom:
                border = p_Range.Borders[XlBordersIndex.xlEdgeBottom];
                break;

            //对角线
            case BordersEdge.xlDiagonalDown:
                border = p_Range.Borders[XlBordersIndex.xlDiagonalDown];
                break;

            case BordersEdge.xlDiagonalUp:
                border = p_Range.Borders[XlBordersIndex.xlDiagonalUp];
                break;

            //边框内部是横竖线(不包括边框)
            case BordersEdge.xlInsideHorizontal:
                border = p_Range.Borders[XlBordersIndex.xlInsideHorizontal];
                break;

            case BordersEdge.xlInsideVertical:
                border = p_Range.Borders[XlBordersIndex.xlInsideVertical];
                break;

            case BordersEdge.xlLineStyleNone:
                //所先范围内所有线都没有
                p_Range.Borders[XlBordersIndex.xlDiagonalDown].LineStyle     = XlLineStyle.xlLineStyleNone;             //xlNone
                p_Range.Borders[XlBordersIndex.xlDiagonalUp].LineStyle       = XlLineStyle.xlLineStyleNone;
                p_Range.Borders[XlBordersIndex.xlEdgeLeft].LineStyle         = XlLineStyle.xlLineStyleNone;
                p_Range.Borders[XlBordersIndex.xlEdgeTop].LineStyle          = XlLineStyle.xlLineStyleNone;
                p_Range.Borders[XlBordersIndex.xlEdgeBottom].LineStyle       = XlLineStyle.xlLineStyleNone;
                p_Range.Borders[XlBordersIndex.xlEdgeRight].LineStyle        = XlLineStyle.xlLineStyleNone;
                p_Range.Borders[XlBordersIndex.xlInsideVertical].LineStyle   = XlLineStyle.xlLineStyleNone;
                p_Range.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlLineStyleNone;
                break;
            }

            if (border != null)
            {
                //XlLineStyle
                XlLineStyle mXlLineStyle = XlLineStyle.xlContinuous;
                switch (p_BordersLineStyle)
                {
                case BordersLineStyle.xlContinuous:
                    mXlLineStyle = XlLineStyle.xlContinuous;
                    break;

                case BordersLineStyle.xlDash:
                    mXlLineStyle = XlLineStyle.xlDash;
                    break;

                case BordersLineStyle.xlDashDot:
                    mXlLineStyle = XlLineStyle.xlDashDot;
                    break;

                case BordersLineStyle.xlDashDotDot:
                    mXlLineStyle = XlLineStyle.xlDashDotDot;
                    break;

                case BordersLineStyle.xlDot:
                    mXlLineStyle = XlLineStyle.xlDot;
                    break;

                case BordersLineStyle.xlDouble:
                    mXlLineStyle = XlLineStyle.xlDouble;
                    break;

                case BordersLineStyle.xlLineStyleNone:
                    mXlLineStyle = XlLineStyle.xlLineStyleNone;
                    break;

                case BordersLineStyle.xlSlantDashDot:
                    mXlLineStyle = XlLineStyle.xlSlantDashDot;
                    break;
                }
                border.LineStyle = mXlLineStyle;

                //XlBorderWeight
                XlBorderWeight mXlBorderWeight = XlBorderWeight.xlThin;

                switch (p_BordersWeight)
                {
                case BordersWeight.xlHairline:
                    mXlBorderWeight = XlBorderWeight.xlHairline;
                    break;

                case BordersWeight.xlMedium:
                    mXlBorderWeight = XlBorderWeight.xlMedium;
                    break;

                case BordersWeight.xlThick:
                    mXlBorderWeight = XlBorderWeight.xlThick;
                    break;

                case BordersWeight.xlThin:
                    mXlBorderWeight = XlBorderWeight.xlThin;
                    break;
                }
                border.Weight = mXlBorderWeight;
            }//End IF
        }
예제 #5
0
 public void SetBordersEdge(int int_0, string string_1, int int_1, string string_2, BordersEdge bordersEdge_0,
                            BordersLineStyle bordersLineStyle_0, BordersWeight bordersWeight_0)
 {
     base.SetBordersEdge(base.GetRange(int_0, string_1, int_1, string_2), bordersEdge_0, bordersLineStyle_0,
                         bordersWeight_0);
 }
예제 #6
0
 public void SetBordersEdge(int int_0, int int_1, int int_2, int int_3, BordersEdge bordersEdge_0,
                            BordersLineStyle bordersLineStyle_0, BordersWeight bordersWeight_0)
 {
     base.SetBordersEdge(base.GetRange(int_0, int_1, int_2, int_3), bordersEdge_0, bordersLineStyle_0,
                         bordersWeight_0);
 }