Esempio n. 1
0
        /// <summary>
        /// Set Border in excel file
        /// </summary>
        /// <param name="range"></param>
        /// <param name="index"></param>
        private void SetBorder(IRange range, BordersIndex index)
        {
            IBorder border = range.Borders[index];

            border.LineStyle = SpreadsheetGear.LineStyle.Continous;
            border.Color     = SpreadsheetGear.Drawing.Color.GetSpreadsheetGearColor(System.Drawing.Color.Black);
            border.Weight    = SpreadsheetGear.BorderWeight.Thin;
        }
        public static IRange SetBorders(this IRange range, BordersIndex borders, LineStyle style, BorderWeight weight, Color color)
        {
            range.Borders[borders].LineStyle = style;
            range.Borders[borders].Weight    = weight;
            range.Borders[borders].Color     = color;
            range.Style.IncludeBorder        = true;

            return(range);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a Border object that represents one of the borders of either a range of cells or a style. This object is internally cached and does not need to be manually disposed.
        /// </summary>
        /// <param name="idx">A variable that represents a Borders object.</param>
        /// <returns>Border</returns>
        public Border this[BordersIndex idx]
        {
            get
            {
                if (!_this.ContainsKey(idx))
                {
                    _this.Add(idx, new Border(InternalObject.GetType().InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, InternalObject, new object[] { idx })));
                }

                return(_this[idx]);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Gets a Border object that represents one of the borders of either a range of cells or a style. This object is internally cached and does not need to be manually disposed.
        /// </summary>
        /// <param name="idx">A variable that represents a Borders object.</param>
        /// <returns>Border</returns>
        public Border this[BordersIndex idx]
        {
            get
            {
                if (!_this.ContainsKey(idx))
                {
                    _this.Add(idx, new Border(InternalObject.GetType().InvokeMember("Item", System.Reflection.BindingFlags.GetProperty, null, InternalObject, new object[] { idx })));
                }

                return _this[idx];
            }
        }
Esempio n. 5
0
        /// <summary>
        /// To set border of a range.
        /// </summary>
        /// <param name="workbook"> Instance of workbook</param>
        /// <param name="worksheetIndex">worksheet index </param>
        /// <param name="startRowIndex">starting row index</param>
        /// <param name="startColIndex">starting column index</param>
        /// <param name="endRowIndex">last row index</param>
        /// <param name="endColIndex">last column index</param>
        /// <param name="lineStyle">line style for border</param>
        /// <param name="borderWeight">weight like thick ,thin ,etc.</param>
        /// <param name="borderColor">color for border</param>
        /// <param name="borderIndex">Index like top , left, botton, etc</param>
        internal static void SetRangeBorders(IWorkbook workbook, int worksheetIndex, int startRowIndex, int startColIndex, int endRowIndex, int endColIndex, LineStyle lineStyle, BorderWeight borderWeight, System.Drawing.Color borderColor, BordersIndex borderIndex)
        {
            SpreadsheetGear.IBorder RangeBorder;
            try
            {
                //get range
                IRange Range = workbook.Worksheets[worksheetIndex].Cells[startRowIndex, startColIndex, endRowIndex, endColIndex];

                RangeBorder = Range.Borders[borderIndex];
                // set border's properties
                ExcelHelper.SetBorderStyle(ref RangeBorder, lineStyle, borderWeight, borderColor);
            }
            catch (Exception ex)
            {
                //                new ApplicationException(ex.ToString());
            }
        }
Esempio n. 6
0
        /// <summary>
        /// To set cell's border .
        /// </summary>
        /// <param name="workbook">Instance of workbook</param>
        /// <param name="worksheetIndex">worksheet index</param>
        ///<param name="rowIndex"></param>
        /// <param name="colIndex"></param>
        /// <param name="lineStyle">line style for border</param>
        /// <param name="borderWeight">weight like thick ,thin ,etc.</param>
        /// <param name="borderColor">color for border</param>
        /// <param name="borderIndex">Index of border like top, left ,..etc</param>
        internal static void SetCellBorder(IWorkbook workbook, int worksheetIndex, int rowIndex, int colIndex, LineStyle lineStyle, BorderWeight borderWeight, System.Drawing.Color borderColor, BordersIndex borderIndex)
        {
            SpreadsheetGear.IRange Cell;
            SpreadsheetGear.IBorder CellBorder;
            try
            {
                // Get a reference to a cell.
                Cell = workbook.Worksheets[worksheetIndex].Cells[rowIndex, colIndex];

                // Get specified border
                CellBorder = Cell.Borders[borderIndex];

                // set border's properties
                ExcelHelper.SetBorderStyle(ref CellBorder, lineStyle, borderWeight, borderColor);
            }
            catch (Exception ex)
            {
                //                new ApplicationException(ex.ToString());
            }
        }
Esempio n. 7
0
 /// <summary>
 /// To set cell's border .
 /// </summary>
 /// <param name="worksheetIndex">worksheet index</param>
 ///<param name="rowIndex"></param>
 /// <param name="colIndex"></param>
 /// <param name="lineStyle">line style for border</param>
 /// <param name="borderWeight">weight like thick ,thin ,etc.</param>
 /// <param name="borderColor">color for border</param>
 /// <param name="borderIndex">Index of border like top, left ,..etc</param>
 public void SetCellBorder(int worksheetIndex, int rowIndex, int colIndex, LineStyle lineStyle, BorderWeight borderWeight, System.Drawing.Color borderColor, BordersIndex borderIndex)
 {
     try
     {
         ExcelHelper.SetCellBorder(this.Workbook, worksheetIndex, rowIndex, colIndex, lineStyle, borderWeight, borderColor, borderIndex);
     }
     catch (Exception ex)
     {
     //                ExceptionFacade.ThrowException(ex);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// To set border of a range.
 /// </summary>
 /// <param name="worksheetIndex">worksheet index </param>
 /// <param name="startRowIndex">starting row index</param>
 /// <param name="startColIndex">starting column index</param>
 /// <param name="endRowIndex">last row index</param>
 /// <param name="endColIndex">last column index</param>
 /// <param name="lineStyle">line style for border</param>
 /// <param name="borderWeight">weight like thick ,thin ,etc.</param>
 /// <param name="borderColor">color for border</param>
 /// <param name="borderIndex">Index like top , left, botton, etc</param>
 public void SetRangeBorder(int worksheetIndex, int startRowIndex, int startColIndex, int endRowIndex, int endColIndex, LineStyle lineStyle, BorderWeight borderWeight, System.Drawing.Color borderColor, BordersIndex borderIndex)
 {
     try
     {
         ExcelHelper.SetRangeBorders(this.Workbook, worksheetIndex, startRowIndex, startColIndex, endRowIndex, endColIndex, lineStyle, borderWeight, borderColor, borderIndex);
     }
     catch (Exception ex)
     {
     //                ExceptionFacade.ThrowException(ex);
     }
 }