Beispiel #1
0
        /// <summary>
        /// Занесение данных в ячейку
        /// </summary>
        /// <param name="text"></param>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="borderWeight"></param>
        /// <param name="borderStyle"></param>
        public void Print(object text, int row, int column, int width = 1, int height = 1, int borderWeight = 0, Microsoft.Office.Interop.Excel.XlLineStyle borderStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous, Color?color = null)
        {
            if (width < 1 || height < 1 || row < 0 | column < 0 || borderWeight < 0)
            {
                throw new Exception("Отрицательные параметры недопустимы!");
            }

            Write(row, column, text);
            if (width > 1 || height > 1)
            {
                MergeCells(column, column + width - 1, row, row + height - 1);
            }
            Borders(row, column, width, height, borderWeight, borderStyle);
            if (color != null)
            {
                FillColor(row, column, color.Value, width, height);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Нанесение границ
 /// </summary>
 /// <param name="row"></param>
 /// <param name="column"></param>
 /// <param name="width"></param>
 /// <param name="height"></param>
 /// <param name="borderWeight"></param>
 /// <param name="borderStyle"></param>
 public void Borders(int row, int column, int width = 1, int height = 1, int borderWeight = 4, Microsoft.Office.Interop.Excel.XlLineStyle borderStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous)
 {
     if (width < 1 || height < 1 || row < 0 | column < 0 || borderWeight < 0)
     {
         throw new Exception("Отрицательные параметры недопустимы!");
     }
     if (borderWeight > 0)
     {
         string startingLiteral = GetCellName(column, row + 1);
         string endLiteral      = GetCellName(column + width - 1, row + height);
         for (int i = 7; i < 11; i++)
         {
             workSheet.get_Range(startingLiteral, endLiteral).Borders[(XlBordersIndex)i].LineStyle = borderStyle;
             workSheet.get_Range(startingLiteral, endLiteral).Borders[(XlBordersIndex)i].Weight    = borderWeight;
         }
     }
 }