Exemplo n.º 1
0
 /// <summary>
 /// 设置 Range 的单元格样式
 /// </summary>
 /// <param name="range"> Range 对象 </param>
 /// <param name="fontSize"> 字体大小 </param>
 /// <param name="fontName"> 字体名称 </param>
 /// <param name="color"> 字体颜色 </param>
 /// <param name="horizontalAlignment"> 水平对齐方式 </param>
 public void SetRangeFormat(Xls.Range range, object fontSize, object
                            fontName, Xls.Constants color, Xls.Constants horizontalAlignment)
 {
     range.Font.Color          = color;
     range.Font.Size           = fontSize;
     range.Font.Name           = fontName;
     range.HorizontalAlignment = horizontalAlignment;
 }
 public RangeStyle(int ColumnWidth, bool WrapText, string FontName, int FontSize, bool FontBold, Color Interior,
                   Excel.Constants HorizontalAligment, Excel.Constants VerticalAligment, Excel.XlLineStyle BorderLineStyle, Excel.XlBorderWeight BorderWeight)
 {
     this.ColumnWidth        = ColumnWidth;
     this.WrapText           = WrapText;
     this.FontName           = FontName;
     this.FontSize           = FontSize;
     this.FontBold           = FontBold;
     this.Interior           = Interior;
     this.HorizontalAligment = HorizontalAligment;
     this.VerticalAligment   = VerticalAligment;
     this.BorderLineStyle    = BorderLineStyle;
     this.BorderWeight       = BorderWeight;
 }
Exemplo n.º 3
0
 public void VerticalAlignmentCells(string startCell, string endCell, Excel.Constants alignment)
 {
     //垂直对齐一行单元格
     excelRange = excelWorkSheet.get_Range(startCell, endCell);
     excelRange.VerticalAlignment = alignment;
 }
Exemplo n.º 4
0
 public void HorizontalAlignmentCells(string startCell, string endCell, Excel.Constants alignment)
 {
     //水平对齐一行单元格
     excelRange = excelWorkSheet.get_Range(startCell, endCell);
     excelRange.HorizontalAlignment = alignment;
 }
Exemplo n.º 5
0
 public void SetOneCellHorizontalAlignment(int CellRowID, int CellColumnID, Excel.Constants alignment)
 {
     excelRange = (Excel.Range)excelWorkSheet.Cells[CellRowID, CellColumnID];
     excelRange.HorizontalAlignment = alignment;
 }
 /// <summary>
 /// 设置单元格属性
 /// </summary>
 public void SetCellProperty(Excel.Worksheet ws, int startRowIndex, int startColumnIndex, int endRowIndex, int endColumnIndex, int size, string name, Excel.Constants color, Excel.Constants horizontalAlignment)
 {
     Excel.Range range = GetRange(ws, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex);
     range.Font.Name           = name;
     range.Font.Size           = size;
     range.Font.Color          = color;
     range.HorizontalAlignment = horizontalAlignment;
 }
        /// <summary>
        /// 设置单元格属性
        /// </summary>
        /// <param name="sheetname"></param>
        /// <param name="startRowIndex"></param>
        /// <param name="startColumnIndex"></param>
        /// <param name="endRowIndex"></param>
        /// <param name="endColumnIndex"></param>
        /// <param name="size"></param>
        /// <param name="name"></param>
        /// <param name="color"></param>
        /// <param name="horizontalAlignment"></param>
        public void SetCellProperty(string sheetname, int startRowIndex, int startColumnIndex, int endRowIndex, int endColumnIndex, int size, string name, Excel.Constants color, Excel.Constants horizontalAlignment)
        {
            Excel.Worksheet ws = GetSheet(sheetname);

            SetCellProperty(ws, startRowIndex, startColumnIndex, endRowIndex, endColumnIndex, size, name, color, horizontalAlignment);
        }
Exemplo n.º 8
0
 public void setOneCellHorizontalAlignment(int iRow, int iCol, Excel.Constants alignment)
 {
     excelRange = (Excel.Range)excelWorkSheet.Cells[iRow, iCol];
     excelRange.HorizontalAlignment = alignment;
 }
Exemplo n.º 9
0
 public void SetCellProperty(Excel.Worksheet ws, int Startx, int Starty, int Endx, int Endy, int size, string name, Excel.Constants color, Excel.Constants HorizontalAlignment)
 //Set the cell property, font, size, color, and alignment.
 {
     name  = "Times New Roman";
     size  = 12;
     color = Excel.Constants.xlAutomatic;
     HorizontalAlignment = Excel.Constants.xlRight;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Name           = name;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Size           = size;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Color          = color;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).HorizontalAlignment = HorizontalAlignment;
 }
        /// <summary>
        /// 设置一个单元格的属性:大小,字体,颜色,对齐方式
        /// </summary>
        /// <param name="wsn">工作表名称</param>
        /// <param name="startx">开始x行</param>
        /// <param name="starty">开始y列</param>
        /// <param name="endx">结束x行</param>
        /// <param name="endy">结束y列</param>
        /// <param name="size">字体大小如:12</param>
        /// <param name="name">字体名称如:宋体</param>
        /// <param name="color">颜色索引</param>
        /// <param name="horizontalAlignment">对齐方式</param>
        /// <param name="bold">是否加粗</param>
        public void SetCellProperty(string wsn, int startx, int starty, int endx, int endy, int size, string name, ColorIndex color, Excel.Constants horizontalAlignment, bool bold)
        {
            //name = "宋体";
            //size = 12;
            //color = Excel.Constants.xlAutomatic;
            //HorizontalAlignment = Excel.Constants.xlRight;

            Excel.Worksheet ws    = GetSheet(wsn);
            Excel.Range     range = ws.Range[ws.Cells[startx, starty], ws.Cells[endx, endy]];
            range.Font.Name           = name;
            range.Font.Size           = size;
            range.Font.ColorIndex     = color;
            range.HorizontalAlignment = horizontalAlignment;
            range.Font.Bold           = bold;
        }
Exemplo n.º 11
0
 public void SetRangeAlignment(int row1, int col1, int row2, int col2, Excel.Constants algn)
 {
     ewsh.Range[ewsh.Cells[row1, col1], ewsh.Cells[row2, col2]].Columns.HorizontalAlignment = algn;
 }
Exemplo n.º 12
0
 public ExcelHeader()
 {
     HorizontalAllignment = Constants.xlCenter;
 }
Exemplo n.º 13
0
        public void SetCellProperty(string wsn, int Startx, int Starty, int Endx, int Endy, int size, string name, Excel.Constants color, Excel.Constants HorizontalAlignment)
        {
            //name = "Times New Roman";
            //size = 12;
            //color = Excel.Constants.xlAutomatic;
            //HorizontalAlignment = Excel.Constants.xlRight;

            Excel.Worksheet ws = GetSheet(wsn);
            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Name  = name;
            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Size  = size;
            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Color = color;

            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).HorizontalAlignment = HorizontalAlignment;
        }
Exemplo n.º 14
0
 public void SetCellProperty(Microsoft.Office.Interop.Excel.Worksheet ws, int Startx, int Starty, int Endx, int Endy, int size, string name, Microsoft.Office.Interop.Excel.Constants color, Microsoft.Office.Interop.Excel.Constants HorizontalAlignment)
 //设置一个单元格的属性   字体,   大小,颜色   ,对齐方式
 {
     name  = "宋体";
     size  = 12;
     color = Microsoft.Office.Interop.Excel.Constants.xlAutomatic;
     HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlRight;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Name           = name;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Size           = size;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Color          = color;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).HorizontalAlignment = HorizontalAlignment;
 }
Exemplo n.º 15
0
 /// <summary>
 /// 设置单元格样式
 /// </summary>
 /// <param name="range">Range对象</param>
 /// <param name="fontSize">字体大小</param>
 /// <param name="fontName">字体名称</param>
 /// <param name="color">字体颜色</param>
 /// <param name="horizontalAlignment">水平对齐方式</param>
 public void SetRangeFormat(Excel.Range range, object fontSize, object fontName, Excel.Constants color, ExcelHorizontalAlignment horizontalAlignment = ExcelHorizontalAlignment.Center)
 {
     range.Font.Color          = color;
     range.Font.Size           = fontSize;
     range.Font.Name           = fontName;
     range.HorizontalAlignment = horizontalAlignment;
 }
Exemplo n.º 16
0
        public void SetCellProperty(string wsn, int Startx, int Starty, int Endx, int Endy, int size, string name, Microsoft.Office.Interop.Excel.Constants color, Microsoft.Office.Interop.Excel.Constants HorizontalAlignment)
        {
            //name = "宋体";
            //size = 12;
            //color = Microsoft.Office.Interop.Excel.Constants.xlAutomatic;
            //HorizontalAlignment = Microsoft.Office.Interop.Excel.Constants.xlRight;

            Microsoft.Office.Interop.Excel.Worksheet ws = GetSheet(wsn);
            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Name  = name;
            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Size  = size;
            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Color = color;

            ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).HorizontalAlignment = HorizontalAlignment;
        }
Exemplo n.º 17
0
 public void SetCellProperty(Microsoft.Office.Interop.Excel.Worksheet ws, int Startx, int Starty, int Endx, int Endy, int size, string name, bool isBold, Microsoft.Office.Interop.Excel.Constants HorizontalAlignment)
 {
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Name           = name;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Size           = size;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).Font.Bold           = isBold;
     ws.get_Range(ws.Cells[Startx, Starty], ws.Cells[Endx, Endy]).HorizontalAlignment = HorizontalAlignment;
 }