2013年11月24日日曜日

BorderAccessor

using OfficeExcel = Microsoft.Office.Interop.Excel;

namespace Core.File.Excel
{
    /// <summary>
    /// ExcelBorderアクセサー
    /// </summary>
    public class BorderAccessor
    {
        #region 構築・破棄

        /// <summary>
        /// コンストラクタ
        /// </summary>
        /// <param name="border"></param>
        private BorderAccessor(OfficeExcel.Border border)
        {
            Border = border;
        }

        /// <summary>
        /// 構成子
        /// </summary>
        /// <param name="border"></param>
        /// <returns></returns>
        internal static BorderAccessor GetAccessor(OfficeExcel.Border border)
        {
            return new BorderAccessor(border);
        }

        #endregion

        #region プロパティ

        /// <summary>border</summary>
        private OfficeExcel.Border Border { get; set; }

        /// <summary>罫線の線の種類</summary>
        public ExcelLineStyle LineStyle
        {
            get
            {
                return Border.LineStyle;
            }
            set
            {
                Border.LineStyle = value;
            }
        }

        /// <summary>罫線の太さ</summary>
        public ExcelBorderWeight Weight
        {
            get
            {
                return Border.Weight;
            }
            set
            {
                Border.Weight = value;
            }
        }

        /// <summary>罫線の色</summary>
        public dynamic Color
        {
            get
            {
                return Border.Color;
            }
            set
            {
                Border.Color = value;
            }
        }

        /// <summary>罫線の色</summary>
        public int ColorIndex
        {
            get
            {
                return Border.ColorIndex;
            }
            set
            {
                Border.ColorIndex = value;
            }
        }

        #endregion
    }

    #region 列挙型

    /// <summary>罫線</summary>
    public enum ExcelBordersIndex
    {
        /// <summary>上端横線</summary>
        EdgeTop = OfficeExcel.XlBordersIndex.xlEdgeTop,
        /// <summary>下端横線</summary>
        EdgeBottom = OfficeExcel.XlBordersIndex.xlEdgeBottom,
        /// <summary>左端縦線</summary>
        EdgeLeft = OfficeExcel.XlBordersIndex.xlEdgeLeft,
        /// <summary>右端縦線</summary>
        EdgeRight = OfficeExcel.XlBordersIndex.xlEdgeRight,
        /// <summary>上下端以外横線</summary>
        InsideHorizontal = OfficeExcel.XlBordersIndex.xlInsideHorizontal,
        /// <summary>左右端以外縦線</summary>
        InsideVertical = OfficeExcel.XlBordersIndex.xlInsideVertical,
        /// <summary>右下がり斜線</summary>
        DiagonalDown = OfficeExcel.XlBordersIndex.xlDiagonalDown,
        /// <summary>右上がり斜線</summary>
        DiagonalUp = OfficeExcel.XlBordersIndex.xlDiagonalUp
    }

    /// <summary>罫線の線の種類</summary>
    public enum ExcelLineStyle
    {
        /// <summary>実線</summary>
        Continuous = OfficeExcel.XlLineStyle.xlContinuous,
        /// <summary>破線</summary>
        Dash = OfficeExcel.XlLineStyle.xlDash,
        /// <summary>一点鎖線</summary>
        DashDot = OfficeExcel.XlLineStyle.xlDashDot,
        /// <summary>二点鎖線</summary>
        DashDotDot = OfficeExcel.XlLineStyle.xlDashDotDot,
        /// <summary>点線</summary>
        Dot = OfficeExcel.XlLineStyle.xlDot,
        /// <summary>二重線</summary>
        Double = OfficeExcel.XlLineStyle.xlDouble,
        /// <summary>線なし</summary>
        LineStyleNone = OfficeExcel.XlLineStyle.xlLineStyleNone,
        /// <summary>斜線</summary>
        SlantDashDot = OfficeExcel.XlLineStyle.xlSlantDashDot
    }

    /// <summary>セル範囲を囲む罫線の太さ</summary>
    public enum ExcelBorderWeight
    {
        /// <summary>極細(最も細い罫線)</summary>
        xlHairline = OfficeExcel.XlBorderWeight.xlHairline,
        /// <summary>中</summary>
        xlMedium = OfficeExcel.XlBorderWeight.xlMedium,
        /// <summary>太い (最も太い罫線)</summary>
        xlThick = OfficeExcel.XlBorderWeight.xlThick,
        /// <summary>細い</summary>
        xlThin = OfficeExcel.XlBorderWeight.xlThin
    }

    #endregion
}

0 件のコメント:

コメントを投稿