示例#1
0
 public void SetColumn(int x, int y, object value, ExcelApp.XlOrientation orientation)
 {
     range                          = _currentSheet.Cells[x, y];
     range.Font.Size                = 8;
     range.NumberFormat             = "@";
     range.Value                    = value;
     range.Orientation              = orientation;
     range.EntireColumn.ColumnWidth = 2;
     range.Borders.LineStyle        = ExcelApp.XlLineStyle.xlContinuous;
     range.Interior.Color           = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.LightGray);
 }
示例#2
0
        private void WorkSheet_SelectionChange(Excel.Range Target)
        {
            //myRange = Target.Copy();

            foreach (Excel.Range cell in Target.Cells)
            {
                Console.WriteLine("Cell " + cell.Address);
                string fontname = ((Excel.Range)cell).Font.Name.ToString();
                Console.WriteLine("\t Font Name = " + fontname);
                Excel.XlHAlign horizontalAlignment = (Excel.XlHAlign)cell.HorizontalAlignment;
                Console.WriteLine("\t Horizontal Alignment = " + horizontalAlignment);
                Excel.XlVAlign verticalalignment = (Excel.XlVAlign)cell.VerticalAlignment;
                Console.WriteLine("\t Vertical Alignment = " + verticalalignment);


                Console.WriteLine("\t Borders Line Style >");

                Console.WriteLine("\t\t Left = " + (Excel.XlLineStyle)cell.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle);
                Console.WriteLine("\t\t Right = " + (Excel.XlLineStyle)cell.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle);
                Console.WriteLine("\t\t Top = " + (Excel.XlLineStyle)cell.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle);
                Console.WriteLine("\t\t Bottom = " + (Excel.XlLineStyle)cell.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle);

                //xlRgbColor에 기록된 컬러만 이용해야 한다.
                Excel.XlRgbColor cellColor = (Excel.XlRgbColor)cell.Interior.Color;
                Console.WriteLine("\t Cell Color = " + cellColor);

                Excel.XlRgbColor fontColor = (Excel.XlRgbColor)cell.Font.Color;
                Console.WriteLine("\t Font Color = " + fontColor);

                bool merged = (bool)cell.MergeCells;
                Console.WriteLine("\tMerged?\t" + merged);
                if (merged)
                {
                    Excel.Range mergeArea = (Excel.Range)cell.MergeArea;
                    Console.WriteLine("\tMerged Area = " + mergeArea.Address);
                }

                Excel.XlOrientation orientation = (Excel.XlOrientation)cell.Orientation;
                Console.WriteLine("\tOrientation(Text Angle) = " + orientation);
            }

            SetText(this.textBox1, Target.Address);
        }