Beispiel #1
0
 public MMRng SetBorders(Color BorderColor, Excel.XlBorderWeight aWeight, Excel.XlLineStyle aLineStyle)
 {
     Rng.Borders.Color     = ColorTranslator.ToOle(BorderColor);
     Rng.Borders.Weight    = aWeight;
     Rng.Borders.LineStyle = aLineStyle;
     return(this);
 }
Beispiel #2
0
        public xlsf SetCellBorder(Excel.XlLineStyle BoarderStyle, Excel.XlBorderWeight BoarderWeight, Color BoarderColor)
        {
            CurrCell.Borders.LineStyle = BoarderStyle;
            CurrCell.Borders.Weight    = BoarderWeight;
            CurrCell.Borders.Color     = ColorTranslator.ToOle(BoarderColor);

            return(this);
        }
Beispiel #3
0
 public void SetValues(int index_color, int weight, Exc.XlLineStyle line_style, int tint_and_shade = 0)
 {
     _MustFormat  = true;
     IndexColor   = index_color;
     TintAndShade = tint_and_shade;
     Weight       = weight;
     LineStyle    = line_style;
 }
Beispiel #4
0
 public void SetValues(int index_color, int weight, int tint_and_shade = 0)
 {
     _MustFormat  = true;
     IndexColor   = index_color;
     TintAndShade = tint_and_shade;
     Weight       = weight;
     LineStyle    = Exc.XlLineStyle.xlContinuous;
 }
Beispiel #5
0
 public BorderParameters(Exc.XlBordersIndex side)
 {
     Side         = side;
     _MustFormat  = false;
     IndexColor   = (int)Exc.XlColorIndex.xlColorIndexNone;
     TintAndShade = 0;
     Weight       = 0;
     LineStyle    = Exc.XlLineStyle.xlLineStyleNone;
 }
Beispiel #6
0
 private void FormatRangeLineInsaide(ExceL.Range rang, ExceL.XlLineStyle style, ExceL.XlBorderWeight weightV, ExceL.XlBorderWeight weightH)
 {
     //Вертикаль
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlInsideVertical).LineStyle = style;
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlInsideVertical).Weight    = weightV;
     //Горизонталь
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlInsideHorizontal).LineStyle = style;
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlInsideHorizontal).Weight    = weightH;
 }
Beispiel #7
0
            /// <summary>
            /// Нарисовать границы ячейки
            /// </summary>
            /// <param name="cells">выбранный диапазон ячеек</param>
            /// <param name="typeBorder">тип линий</param>
            private void paintBorder(Excel.Range cells, int typeBorder)
            {
                Excel.XlLineStyle styleBorder = Excel.XlLineStyle.xlContinuous;

                switch ((Excel.XlLineStyle)typeBorder)
                {
                case Excel.XlLineStyle.xlContinuous:
                    styleBorder = Excel.XlLineStyle.xlContinuous;
                    break;

                case Excel.XlLineStyle.xlDash:
                    styleBorder = Excel.XlLineStyle.xlDash;
                    break;

                case Excel.XlLineStyle.xlDashDot:
                    styleBorder = Excel.XlLineStyle.xlDashDot;
                    break;

                case Excel.XlLineStyle.xlDashDotDot:
                    styleBorder = Excel.XlLineStyle.xlDashDotDot;
                    break;

                case Excel.XlLineStyle.xlDot:
                    break;

                case Excel.XlLineStyle.xlDouble:
                    break;

                case Excel.XlLineStyle.xlSlantDashDot:
                    break;

                case Excel.XlLineStyle.xlLineStyleNone:
                    break;

                default:
                    break;
                }
                // внутренние вертикальные
                cells.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = styleBorder;
                // внутренние горизонтальные
                cells.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = styleBorder;
                // верхняя внешняя
                cells.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = styleBorder;
                // правая внешняя
                cells.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = styleBorder;
                // левая внешняя
                cells.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = styleBorder;
                // нижняя внешняя
                cells.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = styleBorder;
            }
 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;
 }
Beispiel #9
0
 /// <summary>
 /// Форматирует границы диапазона
 /// </summary>
 /// <param name="rang">Рабочий диапазон</param>
 private void FormatRangeLineBorder(ExceL.Range rang, ExceL.XlLineStyle style, ExceL.XlBorderWeight weight)
 {
     //Слево
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeLeft).LineStyle = style;
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeLeft).Weight    = weight;
     //Сверху
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeTop).LineStyle = style;
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeTop).Weight    = weight;
     //Право
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeRight).LineStyle = style;
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeRight).Weight    = weight;
     //Низ
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeBottom).LineStyle = style;
     rang.Borders.get_Item(ExceL.XlBordersIndex.xlEdgeBottom).Weight    = weight;
 }
Beispiel #10
0
        public static void DrawBorders(Excel.Worksheet oSheet, int row1, int col1, int row2, int col2, Excel.XlLineStyle lef_l, Excel.XlBorderWeight lef_w,
                                       Excel.XlLineStyle top_l, Excel.XlBorderWeight top_w, Excel.XlLineStyle rig_l, Excel.XlBorderWeight rig_w,
                                       Excel.XlLineStyle bot_l, Excel.XlBorderWeight bot_w, Excel.XlLineStyle ver_l, Excel.XlBorderWeight ver_w,
                                       Excel.XlLineStyle hor_l, Excel.XlBorderWeight hor_w)
        {
            Excel.Range rg = oSheet.get_Range(GetColumnName(col1) + row1, GetColumnName(col2) + row2);

            rg.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = lef_l;
            if (lef_l != Excel.XlLineStyle.xlLineStyleNone)
            {
                rg.Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight = lef_w;
            }

            rg.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = top_l;
            if (top_l != Excel.XlLineStyle.xlLineStyleNone)
            {
                rg.Borders[Excel.XlBordersIndex.xlEdgeTop].Weight = top_w;
            }

            rg.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = bot_l;
            if (bot_l != Excel.XlLineStyle.xlLineStyleNone)
            {
                rg.Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight = bot_w;
            }

            rg.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = rig_l;
            if (rig_l != Excel.XlLineStyle.xlLineStyleNone)
            {
                rg.Borders[Excel.XlBordersIndex.xlEdgeRight].Weight = rig_w;
            }

            rg.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = ver_l;
            if (ver_l != Excel.XlLineStyle.xlLineStyleNone)
            {
                rg.Borders[Excel.XlBordersIndex.xlInsideVertical].Weight = ver_w;
            }

            rg.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = hor_l;
            if (hor_l != Excel.XlLineStyle.xlLineStyleNone)
            {
                rg.Borders[Excel.XlBordersIndex.xlInsideHorizontal].Weight = hor_w;
            }
        }
Beispiel #11
0
 public void MergeCells(int Pi_Row1, int Pi_Col1, int Pi_Row2, int Pi_Col2, Excel.XlLineStyle LineStyle)
 {
     Excel.Range Le_Range = null;
     try
     {
         Le_Range                   = Mws_Sheet.get_Range(Mws_Sheet.Cells[Pi_Row1, Pi_Col1], Mws_Sheet.Cells[Pi_Row2, Pi_Col2]);
         Le_Range.MergeCells        = true;
         Le_Range.Borders.LineStyle = LineStyle;
     }
     catch (Exception)
     {
         throw;
     }
     finally
     {
         if (Le_Range != null)
         {
             Marshal.ReleaseComObject(Le_Range);
         }
     }
 }
Beispiel #12
0
        internal void BorderAround(ExcelInterop.Range range, ExcelInterop.XlLineStyle lineStyle, ExcelInterop.XlBorderWeight Weight, int colorIndex)
        {
            ExcelInterop.Borders borders = range.Borders;
            borders[ExcelInterop.XlBordersIndex.xlEdgeLeft].ColorIndex = colorIndex;
            borders[ExcelInterop.XlBordersIndex.xlEdgeLeft].LineStyle  = lineStyle;
            borders[ExcelInterop.XlBordersIndex.xlEdgeLeft].Weight     = Weight;

            borders[ExcelInterop.XlBordersIndex.xlEdgeTop].ColorIndex = colorIndex;
            borders[ExcelInterop.XlBordersIndex.xlEdgeTop].LineStyle  = lineStyle;
            borders[ExcelInterop.XlBordersIndex.xlEdgeTop].Weight     = Weight;

            borders[ExcelInterop.XlBordersIndex.xlEdgeBottom].ColorIndex = colorIndex;
            borders[ExcelInterop.XlBordersIndex.xlEdgeBottom].LineStyle  = lineStyle;
            borders[ExcelInterop.XlBordersIndex.xlEdgeBottom].Weight     = Weight;

            borders[ExcelInterop.XlBordersIndex.xlEdgeRight].ColorIndex = colorIndex;
            borders[ExcelInterop.XlBordersIndex.xlEdgeRight].LineStyle  = lineStyle;
            borders[ExcelInterop.XlBordersIndex.xlEdgeRight].Weight     = Weight;

            ////borders.Color = color;
            ExcelApplication.ReleaseComObject(borders);
            borders = null;
        }
Beispiel #13
0
        /// <summary>
        /// DrawLine
        /// </summary>
        /// <param name="point_a"></param>
        /// <param name="point_b"></param>
        /// <param name="position"></param>
        /// <param name="style"></param>
        /// <param name="weight"></param>
        /// <param name="color"></param>
        public void DrawLine(string point_a, string point_b, string position, Excel.XlLineStyle style = Excel.XlLineStyle.xlContinuous, Excel.XlBorderWeight weight = Excel.XlBorderWeight.xlThin, Color?color = null)
        {
            Color line_color = color ?? Color.FromArgb(0, 0, 0);

            switch (position)
            {
            case "top":
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = style;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeTop].Weight    = weight;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeTop].Color     = line_color;
                break;

            case "bottom":
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = style;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight    = weight;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeBottom].Color     = line_color;
                break;

            case "left":
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = style;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight    = weight;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeLeft].Color     = line_color;
                break;

            case "right":
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = style;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeRight].Weight    = weight;
                sheet1.Range[point_a, point_b].Borders[Excel.XlBordersIndex.xlEdgeRight].Color     = line_color;
                break;

            case "all":
                sheet1.Range[point_a, point_b].Borders.LineStyle = style;
                sheet1.Range[point_a, point_b].Borders.Weight    = weight;
                sheet1.Range[point_a, point_b].Borders.Color     = line_color;
                break;
            }
        }
Beispiel #14
0
        public static void DrawBorders(Microsoft.Office.Interop.Excel.Range rg, Excel.XlLineStyle line, Excel.XlBorderWeight weight)
        {
            try
            {
                rg.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle = line;
                rg.Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight    = weight;

                rg.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle = line;
                rg.Borders[Excel.XlBordersIndex.xlEdgeTop].Weight    = weight;

                rg.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle = line;
                rg.Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight    = weight;

                rg.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle = line;
                rg.Borders[Excel.XlBordersIndex.xlEdgeRight].Weight    = weight;

                rg.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle = line;
                rg.Borders[Excel.XlBordersIndex.xlInsideVertical].Weight    = weight;

                rg.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = line;
                rg.Borders[Excel.XlBordersIndex.xlInsideHorizontal].Weight    = weight;
            }
            catch {}
        }
Beispiel #15
0
 public void SetRightBorder(Excel.XlLineStyle style)
 {
     this._rightBorder.LineStyle = style;
 }
Beispiel #16
0
        //EXPORT FACADE VIDE POUR PLEIN
        public static void exportfacadevidepourplein(Excel.Application xlapp, Excel.Workbook workbook, double surfacemur, Dictionary <ElementId, double> dicfenvitre, List <List <string> > nomtypefen, double surfacefenetre, double surfacerideau, double ratio, int comptemur)
        {
            object misvalue = System.Reflection.Missing.Value;

            Excel.Worksheet worksheet4 = workbook.Sheets.Add(misvalue, workbook.Sheets.Item[3]);
            worksheet4.Columns.ColumnWidth = 30;
            worksheet4.Name = "Façade vide pour plein";
            Excel.XlBordersIndex lgauche   = Excel.XlBordersIndex.xlEdgeLeft;
            Excel.XlBordersIndex ldroite   = Excel.XlBordersIndex.xlEdgeRight;
            Excel.XlBordersIndex lhaut     = Excel.XlBordersIndex.xlEdgeTop;
            Excel.XlBordersIndex lbas      = Excel.XlBordersIndex.xlEdgeBottom;
            Excel.XlLineStyle    lcontinue = Excel.XlLineStyle.xlContinuous;
            Excel.XlBorderWeight llarge    = Excel.XlBorderWeight.xlMedium;
            Excel.XlRgbColor     gold      = Excel.XlRgbColor.rgbGold;
            Excel.XlRgbColor     vert      = Excel.XlRgbColor.rgbLightGreen;
            Excel.XlRgbColor     gris      = Excel.XlRgbColor.rgbLightGrey;

            Excel.Range rangetitre1 = worksheet4.Range["A1"];
            rangetitre1.Value      = "FACADE VIDE POUR PLEIN";
            rangetitre1.Font.Size  = 14;
            rangetitre1.Font.Color = Excel.XlRgbColor.rgbRed;
            rangetitre1.Font.Bold  = true;

            Excel.Range rangetitre2 = worksheet4.Range["D1"];
            rangetitre2.Value          = "Liste des fenêtres";
            rangetitre2.Font.Bold      = true;
            rangetitre2.Interior.Color = gold;
            rangetitre2.BorderAround2(lcontinue, llarge);


            worksheet4.Range["A3"].Value     = "Surface de façade ";
            worksheet4.Range["A3"].Font.Bold = true;
            worksheet4.Range["A3", "B3"].BorderAround2(lcontinue, llarge);
            worksheet4.Range["A3", "B3"].Interior.Color = vert;

            worksheet4.Range["A5"].Value     = "Surface de façade vitrée ";
            worksheet4.Range["A5"].Font.Bold = true;
            worksheet4.Range["A5", "B5"].BorderAround2(lcontinue, llarge);
            worksheet4.Range["A5", "B5"].Interior.Color = vert;

            worksheet4.Range["A7"].Value     = "Ratio";
            worksheet4.Range["A7"].Font.Bold = true;
            worksheet4.Range["A7", "B7"].BorderAround2(lcontinue, llarge);
            worksheet4.Range["A7", "B7"].Interior.Color = vert;

            worksheet4.Range["A10"].Value     = "Nombre de murs rideau trouvés ";
            worksheet4.Range["A10"].Font.Bold = true;
            worksheet4.Range["A10", "B10"].BorderAround2(lcontinue, llarge);
            worksheet4.Range["A10", "B10"].Interior.Color = vert;
            worksheet4.Range["B10"].Value = comptemur;

            worksheet4.Range["D2"].Value          = "Famille";
            worksheet4.Range["D2"].Font.Bold      = true;
            worksheet4.Range["D2"].Interior.Color = gold;
            worksheet4.Range["E2"].Value          = "Type";
            worksheet4.Range["E2"].Font.Bold      = true;
            worksheet4.Range["E2"].Interior.Color = gold;
            worksheet4.Range["F2"].Value          = "Surface";
            worksheet4.Range["F2"].Font.Bold      = true;
            worksheet4.Range["F2"].Interior.Color = gold;
            worksheet4.Range["D2", "F2"].BorderAround2(lcontinue, llarge);
            try
            {
                worksheet4.Cells[3, 2] = surfacemur;
                worksheet4.Cells[5, 2] = surfacerideau + surfacefenetre;
                worksheet4.Cells[7, 2] = ratio;

                int y = 2;
                foreach (ElementId wintypeid in dicfenvitre.Keys)
                {
                    y += 1;
                    Excel.Range famcell = worksheet4.Cells[y, 4];
                    famcell.Value = nomtypefen[y - 3][0];
                    Excel.Range typecell = worksheet4.Cells[y, 5];
                    typecell.Value = nomtypefen[y - 3][1];
                    Excel.Range surfcell = worksheet4.Cells[y, 6];
                    surfcell.Value = dicfenvitre[wintypeid];
                    if (y % 2 == 0)
                    {
                        famcell.Interior.Color  = gris;
                        typecell.Interior.Color = gris;
                        surfcell.Interior.Color = gris;
                    }
                }
                string      fenBG     = "D" + y.ToString();
                string      fenBD     = "F" + y.ToString();
                Excel.Range rangefenG = worksheet4.Range["D3", fenBG];
                Excel.Range rangefenD = worksheet4.Range["F3", fenBD];
                Excel.Range rangefenB = worksheet4.Range[fenBG, fenBD];
                rangefenG.Borders[lgauche].LineStyle = lcontinue;
                rangefenG.Borders[lgauche].Weight    = llarge;
                rangefenD.Borders[ldroite].Weight    = llarge;
                rangefenD.Borders[ldroite].LineStyle = lcontinue;
                rangefenB.Borders[lbas].LineStyle    = lcontinue;
                rangefenB.Borders[lbas].Weight       = llarge;
            }
            catch (Exception)
            {
            }
        }
Beispiel #17
0
        //EXPORT DES BUREAUX
        public static void Exportbureaulot(List <Document> docs, Excel.Application xlapp, Excel.Workbook workbook, Dictionary <string, List <double> > dicoBlot, Dictionary <ElementId, List <double> > dicoBetage, Dictionary <ElementId, Dictionary <string, double> > dicolotlevel)
        {
            object misvalue = System.Reflection.Missing.Value;

            Excel.Worksheet worksheet3 = workbook.Sheets[1];
            worksheet3.Columns.ColumnWidth = 20;
            worksheet3.Name = "Bureaux";
            if (dicoBlot.Count != 0)
            {
                Excel.XlBordersIndex lgauche   = Excel.XlBordersIndex.xlEdgeLeft;
                Excel.XlBordersIndex ldroite   = Excel.XlBordersIndex.xlEdgeRight;
                Excel.XlBordersIndex lhaut     = Excel.XlBordersIndex.xlEdgeTop;
                Excel.XlBordersIndex lbas      = Excel.XlBordersIndex.xlEdgeBottom;
                Excel.XlLineStyle    lcontinue = Excel.XlLineStyle.xlContinuous;
                Excel.XlBorderWeight llarge    = Excel.XlBorderWeight.xlMedium;
                Excel.XlBorderWeight lfin      = Excel.XlBorderWeight.xlThin;
                Excel.XlRgbColor     gold      = Excel.XlRgbColor.rgbGold;
                Excel.XlRgbColor     vert      = Excel.XlRgbColor.rgbLightGreen;
                Excel.XlRgbColor     gris      = Excel.XlRgbColor.rgbLightGrey;

                Excel.Range rangetitre1 = worksheet3.Range["A1"];
                rangetitre1.Value      = "BUREAUX";
                rangetitre1.Font.Bold  = true;
                rangetitre1.Font.Size  = 14;
                rangetitre1.Font.Color = Excel.XlRgbColor.rgbRed;

                worksheet3.Range["A3"].Value = "Surface totale de bureau";
                worksheet3.Range["A3", "B3"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A3", "B3"].Interior.Color = vert;

                worksheet3.Range["A5"].Value = "Surface totale de salle de réunion";
                worksheet3.Range["A5", "B5"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A5", "B5"].Interior.Color = vert;

                worksheet3.Range["A7"].Value = "Ratio REU/BUR";
                worksheet3.Range["A7", "B7"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A7", "B7"].Interior.Color = vert;

                worksheet3.Range["D3"].Value = "Nombre total de lot";
                worksheet3.Range["D3", "D4"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["D3", "D4"].Interior.Color = vert;
                worksheet3.Range["D6"].Value = "Surface moyenne d'un lot";
                worksheet3.Range["D6", "D7"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["D6", "D7"].Interior.Color = vert;

                //SURFACE PAR ETAGE
                worksheet3.Range["A13"].Value     = "SURFACE PAR ETAGE";
                worksheet3.Range["A13"].Font.Bold = true;
                worksheet3.Range["A13"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A13"].Interior.Color = gold;
                worksheet3.Range["A14"].Value          = "ETAGE";
                worksheet3.Range["A14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["B14"].Value = "BUREAUX";
                worksheet3.Range["B14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["C14"].Value = "REUNIONS";
                worksheet3.Range["C14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["D14"].Value = "RATIO";
                worksheet3.Range["D14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A14", "D14"].Interior.Color = gold;

                int i         = 14;
                int nombrelot = dicoBlot.Keys.Count;
                worksheet3.Cells[4, 4] = nombrelot;
                double sommebureaux = 0;
                double sommereu     = 0;
                foreach (ElementId etageid in dicoBetage.Keys)
                {
                    i += 1;
                    string nometage = "";
                    //on recupere le nom de l'etage en fonction de son document
                    foreach (Document doc in docs)
                    {
                        try
                        {
                            nometage = doc.GetElement(etageid).Name;
                            break;
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    Excel.Range etagecell = worksheet3.Cells[i, 1];
                    etagecell.Value = nometage;
                    etagecell.BorderAround2(lcontinue, lfin);
                    Excel.Range burcell = worksheet3.Cells[i, 2];
                    burcell.Value = dicoBetage[etageid][0];
                    burcell.BorderAround2(lcontinue, lfin);
                    Excel.Range reucell = worksheet3.Cells[i, 3];
                    reucell.Value = dicoBetage[etageid][1];
                    reucell.BorderAround2(lcontinue, lfin);
                    sommebureaux += dicoBetage[etageid][0];
                    sommereu     += dicoBetage[etageid][1];
                    double ratiot = dicoBetage[etageid][1] / dicoBetage[etageid][0];
                    ratiot = Math.Round(ratiot, 2);
                    Excel.Range ratiocell = worksheet3.Cells[i, 4];
                    ratiocell.Value = ratiot;
                    ratiocell.BorderAround2(lcontinue, lfin);
                    string      setageMG    = "A" + i.ToString();
                    string      setageMD    = "D" + i.ToString();
                    Excel.Range rangeetageM = worksheet3.Range[setageMG, setageMD];
                    rangeetageM.Borders[lbas].LineStyle = lcontinue;
                    rangeetageM.Borders[lbas].Weight    = llarge;
                    if (i % 2 == 0)
                    {
                        etagecell.Interior.Color = gris;
                        burcell.Interior.Color   = gris;
                        reucell.Interior.Color   = gris;
                        ratiocell.Interior.Color = gris;
                    }
                }
                //TOTAUX
                worksheet3.Range["B3"].Value = sommebureaux;
                worksheet3.Range["B5"].Value = sommereu;
                double ratiooo = (sommereu / sommebureaux);
                ratiooo = Math.Round(ratiooo, 2);
                worksheet3.Range["B7"].Value = ratiooo;
                string      setageMGB     = "B" + i.ToString();
                string      setageBD      = "D" + i.ToString();
                Excel.Range rangeetageMGV = worksheet3.Range["B15", setageMGB];
                Excel.Range rangeetageD   = worksheet3.Range["D15", setageBD];
                rangeetageD.Borders[ldroite].LineStyle   = lcontinue;
                rangeetageD.Borders[ldroite].Weight      = llarge;
                rangeetageD.Borders[lgauche].LineStyle   = lcontinue;
                rangeetageMGV.Borders[lgauche].LineStyle = lcontinue;
                rangeetageMGV.Borders[lgauche].LineStyle = lcontinue;

                //SURFACE PAR LOT
                Excel.Range rangetitre2 = worksheet3.Range["F13"];
                rangetitre2.Value = "SURFACE PAR LOT";
                rangetitre2.BorderAround2(lcontinue, llarge);
                rangetitre2.Interior.Color    = gold;
                rangetitre2.Font.Bold         = true;
                worksheet3.Range["F14"].Value = "NOM LOT";
                worksheet3.Range["F14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["G14"].Value = "SURFACE LOT";
                worksheet3.Range["G14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["H14"].Value = "BUREAUX";
                worksheet3.Range["H14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["I14"].Value = "REUNIONS";
                worksheet3.Range["I14"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["F14", "I14"].Interior.Color = gold;

                int    j           = 14;
                double sommetotlot = 0;
                foreach (string lot in dicoBlot.Keys)
                {
                    j += 1;
                    Excel.Range nomlot = worksheet3.Cells[j, 6];
                    nomlot.Value = lot;
                    nomlot.BorderAround2(lcontinue, lfin);
                    Excel.Range surlot = worksheet3.Cells[j, 7];
                    surlot.Value = dicoBlot[lot][0];
                    surlot.BorderAround2(lcontinue, lfin);
                    Excel.Range surbur = worksheet3.Cells[j, 8];
                    surbur.Value = dicoBlot[lot][1];
                    surbur.BorderAround2(lcontinue, lfin);
                    Excel.Range surreu = worksheet3.Cells[j, 9];
                    surreu.Value = dicoBlot[lot][2];
                    surreu.BorderAround2(lcontinue, lfin);
                    sommetotlot += dicoBlot[lot][0];
                    if (j % 2 == 0)
                    {
                        nomlot.Interior.Color = gris;
                        surlot.Interior.Color = gris;
                        surbur.Interior.Color = gris;
                        surreu.Interior.Color = gris;
                    }
                }
                double moyennelot = (sommetotlot / nombrelot);
                moyennelot = Math.Round(moyennelot, 2);
                worksheet3.Range["D7"].Value = moyennelot;
                string      lotBG     = "F" + j.ToString();
                string      lotH      = "H" + j.ToString();
                string      lotI      = "I" + j.ToString();
                Excel.Range rangelotG = worksheet3.Range["F15", lotBG];
                Excel.Range rangelotH = worksheet3.Range["H15", lotH];
                Excel.Range rangelotI = worksheet3.Range["I15", lotI];
                rangelotI.Borders[ldroite].LineStyle = lcontinue;
                rangelotI.Borders[ldroite].Weight    = llarge;
                rangelotH.Borders[ldroite].LineStyle = lcontinue;
                rangelotH.Borders[lgauche].LineStyle = lcontinue;
                rangelotG.Borders[lgauche].LineStyle = lcontinue;
                rangelotG.Borders[lgauche].Weight    = llarge;
                rangelotG.Borders[ldroite].LineStyle = lcontinue;

                //NOMBRE DE LOT PAR ETAGE
                Excel.Range rangetitre3 = worksheet3.Range["K14", "L14"];
                rangetitre3.Merge();
                rangetitre3.Value = "SURFACE DE LOT PAR ETAGE (m²)";
                rangetitre3.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
                rangetitre3.BorderAround2(lcontinue, llarge);
                rangetitre3.Font.Bold      = true;
                rangetitre3.Interior.Color = gold;

                int maxL = 0;
                int k    = 13;
                foreach (ElementId etageid in dicolotlevel.Keys)
                {
                    k += 2;
                    string nometage = "";
                    //on recupere le nom de l'etage en fonction de son document
                    foreach (Document doc in docs)
                    {
                        try
                        {
                            nometage = doc.GetElement(etageid).Name;
                            break;
                        }
                        catch
                        {
                            continue;
                        }
                    }
                    Excel.Range etagecell = worksheet3.Cells[k, 11];
                    etagecell.Value = nometage;
                    Excel.Range nbrlotcell = worksheet3.Cells[k + 1, 11];
                    nbrlotcell.Value = dicolotlevel[etageid].Count.ToString() + " lots";
                    Excel.Range countcell = worksheet3.Range[worksheet3.Cells[k, 11], worksheet3.Cells[k + 1, 11]];
                    countcell.BorderAround2(lcontinue, lfin);

                    int L = 11;
                    foreach (string nomlot in dicolotlevel[etageid].Keys)
                    {
                        L += 1;
                        Excel.Range lotcell = worksheet3.Cells[k, L];
                        lotcell.Value = nomlot;
                        Excel.Range surlotcell = worksheet3.Cells[k + 1, L];
                        surlotcell.Value = dicolotlevel[etageid][nomlot];
                        worksheet3.Range[lotcell, surlotcell].BorderAround2(lcontinue, lfin);
                    }
                    if (maxL < L)
                    {
                        maxL = L;
                    }
                }
                int x = 14;
                while (x < k)
                {
                    x += 1;
                    Excel.Range cellHG         = worksheet3.Cells[x, 11];
                    Excel.Range lotetatD       = worksheet3.Cells[x, maxL];
                    Excel.Range rangelotetatMH = worksheet3.Range[cellHG, lotetatD];
                    rangelotetatMH.Interior.Color = Excel.XlRgbColor.rgbLightGrey;
                    x             += 1;
                    cellHG         = worksheet3.Cells[x, 11];
                    lotetatD       = worksheet3.Cells[x, maxL];
                    rangelotetatMH = worksheet3.Range[cellHG, lotetatD];
                    rangelotetatMH.Borders[lbas].LineStyle = lcontinue;
                    rangelotetatMH.Borders[lbas].Weight    = llarge;
                }
                int y = 10;
                while (y < maxL)
                {
                    y += 1;
                    Excel.Range cellhaute    = worksheet3.Cells[15, y];
                    Excel.Range cellbasse    = worksheet3.Cells[k + 1, y];
                    Excel.Range rangehautbas = worksheet3.Range[cellhaute, cellbasse];
                    rangehautbas.Borders[ldroite].LineStyle = lcontinue;
                }
                string      lotetaBG      = "K" + (k + 1).ToString();
                Excel.Range lotetatHD     = worksheet3.Cells[15, maxL];
                Excel.Range lotetatBD     = worksheet3.Cells[(k + 1), maxL];
                Excel.Range rangeetatD    = worksheet3.Range[lotetatHD, lotetatBD];
                Excel.Range rangelotetaG  = worksheet3.Range["K15", lotetaBG];
                Excel.Range rangelotetatH = worksheet3.Range["K15", lotetatHD];
                Excel.Range rangelotetatB = worksheet3.Range[lotetaBG, lotetatBD];
                rangelotetatB.Borders[lbas].LineStyle   = lcontinue;
                rangelotetatB.Borders[lbas].Weight      = llarge;
                rangelotetatH.Borders[lhaut].LineStyle  = lcontinue;
                rangelotetatH.Borders[lhaut].Weight     = llarge;
                rangelotetaG.Borders[lgauche].LineStyle = lcontinue;
                rangelotetaG.Borders[lgauche].Weight    = llarge;
                rangeetatD.Borders[ldroite].LineStyle   = lcontinue;
                rangeetatD.Borders[ldroite].Weight      = llarge;
            }
            else
            {
                revitui.TaskDialog.Show("Erreur", "Aucune pièce 'bureau' trouvée. L'export des lots et bureaux vers Excel ne sera pas réalisé.");
            }
        }
Beispiel #18
0
 public void SetBorderAroundInRange(string range, ExcelFile.XlLineStyle lineStyle, ExcelFile.XlBorderWeight weight, ExcelFile.XlColorIndex colorIndex)
 {
     _excel.get_Range(range).BorderAround(lineStyle, weight, colorIndex);
 }
Beispiel #19
0
 public void SetBordersLineStyleInRange(string range, ExcelFile.XlLineStyle lineStyle)
 {
     _excel.get_Range(range).Borders.LineStyle = lineStyle;
 }
Beispiel #20
0
 public void SetBorder(int Sheet, int ColFrom, int RowFrom, int ColTo, int RowTo, Excel.XlLineStyle LineStyle)
 {
     SelectCells(Sheet, ColFrom, RowFrom, ColTo, RowTo).Borders.LineStyle = LineStyle;
 }
Beispiel #21
0
        /// <summary>
        /// 设置单元格边框(只能设置单个单元格的边框)
        /// </summary>
        /// <param name="range">Range对象</param>
        /// <param name="bordersEdge">单元格边框范围</param>
        /// <param name="ExcelBordersEdge">单元格边线</param>
        /// <param name="bordersLineStyle">边框线条分隔</param>
        /// <param name="bordersWeight">边框线粗细</param>
        public void SetCellsBorder(Excel.Range range, ExcelBordersEdge bordersEdge, ExcelBordersLineStyle bordersLineStyle, ExcelBorderWeight bordersWeight)
        {
            //range.Select();
            Excel.Border border = null;

            switch (bordersEdge)
            {
            //左右顶底的线
            case ExcelBordersEdge.EdgeLeft:
                border = range.Borders[Excel.XlBordersIndex.xlEdgeLeft];
                break;

            case ExcelBordersEdge.EdgeRight:
                border = range.Borders[Excel.XlBordersIndex.xlEdgeRight];
                break;

            case ExcelBordersEdge.EdgeTop:
                border = range.Borders[Excel.XlBordersIndex.xlEdgeTop];
                break;

            case ExcelBordersEdge.EdgeBottom:
                border = range.Borders[Excel.XlBordersIndex.xlEdgeBottom];
                break;

            //对角线
            case ExcelBordersEdge.DiagonalDown:
                border = range.Borders[Excel.XlBordersIndex.xlDiagonalDown];
                break;

            case ExcelBordersEdge.DiagonUp:
                border = range.Borders[Excel.XlBordersIndex.xlDiagonalUp];
                break;

            //边框内部是横竖线(不包括边框)
            case ExcelBordersEdge.InsideHorizontal:
                border = range.Borders[Excel.XlBordersIndex.xlInsideHorizontal];
                break;

            case ExcelBordersEdge.InsideVertical:
                border = range.Borders[Excel.XlBordersIndex.xlInsideVertical];
                break;

            case ExcelBordersEdge.LineStyleNone:
                //所先范围内所有线都没有
                range.Borders[Excel.XlBordersIndex.xlDiagonalDown].LineStyle     = Excel.XlLineStyle.xlLineStyleNone;           //xlNone
                range.Borders[Excel.XlBordersIndex.xlDiagonalUp].LineStyle       = Excel.XlLineStyle.xlLineStyleNone;
                range.Borders[Excel.XlBordersIndex.xlEdgeLeft].LineStyle         = Excel.XlLineStyle.xlLineStyleNone;
                range.Borders[Excel.XlBordersIndex.xlEdgeTop].LineStyle          = Excel.XlLineStyle.xlLineStyleNone;
                range.Borders[Excel.XlBordersIndex.xlEdgeBottom].LineStyle       = Excel.XlLineStyle.xlLineStyleNone;
                range.Borders[Excel.XlBordersIndex.xlEdgeRight].LineStyle        = Excel.XlLineStyle.xlLineStyleNone;
                range.Borders[Excel.XlBordersIndex.xlInsideVertical].LineStyle   = Excel.XlLineStyle.xlLineStyleNone;
                range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
                break;
            }

            if (border != null)
            {
                //XlLineStyle
                Excel.XlLineStyle mXlLineStyle = Excel.XlLineStyle.xlContinuous;
                switch (bordersLineStyle)
                {
                case ExcelBordersLineStyle.Continious:
                    mXlLineStyle = Excel.XlLineStyle.xlContinuous;
                    break;

                case ExcelBordersLineStyle.Dash:
                    mXlLineStyle = Excel.XlLineStyle.xlDash;
                    break;

                case ExcelBordersLineStyle.DashDot:
                    mXlLineStyle = Excel.XlLineStyle.xlDashDot;
                    break;

                case ExcelBordersLineStyle.DashDotDot:
                    mXlLineStyle = Excel.XlLineStyle.xlDashDotDot;
                    break;

                case ExcelBordersLineStyle.Dot:
                    mXlLineStyle = Excel.XlLineStyle.xlDot;
                    break;

                case ExcelBordersLineStyle.Double:
                    mXlLineStyle = Excel.XlLineStyle.xlDouble;
                    break;

                case ExcelBordersLineStyle.StyleNone:
                    mXlLineStyle = Excel.XlLineStyle.xlLineStyleNone;
                    break;

                case ExcelBordersLineStyle.SlantDashDot:
                    mXlLineStyle = Excel.XlLineStyle.xlSlantDashDot;
                    break;
                }
                border.LineStyle = mXlLineStyle;

                //XlBorderWeight
                Excel.XlBorderWeight mXlBorderWeight = Excel.XlBorderWeight.xlThin;

                switch (bordersWeight)
                {
                case ExcelBorderWeight.Hairline:
                    mXlBorderWeight = Excel.XlBorderWeight.xlHairline;
                    break;

                case ExcelBorderWeight.Medium:
                    mXlBorderWeight = Excel.XlBorderWeight.xlMedium;
                    break;

                case ExcelBorderWeight.Thick:
                    mXlBorderWeight = Excel.XlBorderWeight.xlThick;
                    break;

                case ExcelBorderWeight.Thin:
                    mXlBorderWeight = Excel.XlBorderWeight.xlThin;
                    break;
                }
                border.Weight = mXlBorderWeight;
            }//end if
        }
Beispiel #22
0
 public ExcelBorder(Excel.XlLineStyle lineStyle, Excel.XlBorderWeight weight, ExcelColorIndex?borderColor)
 {
     LineStyle   = lineStyle;
     Weight      = weight;
     BorderColor = borderColor;
 }
Beispiel #23
0
        }                                                                                     //, xlFontName, xlFontSize

        private void setBorderCelda(XLExcel.Range xlRange, XLExcel.XlBorderWeight xlWeight = XLExcel.XlBorderWeight.xlThin, XLExcel.XlLineStyle xlLineStyle = XLExcel.XlLineStyle.xlContinuous, Boolean xlClearStyle = true, Boolean xlEdgeLeft = true, Boolean xlEdgeTop = true, Boolean xlEdgeRight = true, Boolean xlEdgeBottom = true, Boolean xlInsideVertical = true, Boolean xlInsideHorizontal = true, Boolean xlDiagonalDown = true, Boolean xlDiagonalUp = true)
        {
            if (xlClearStyle)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlDiagonalDown].LineStyle     = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlDiagonalUp].LineStyle       = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeLeft].LineStyle         = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeTop].LineStyle          = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeBottom].LineStyle       = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeRight].LineStyle        = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideVertical].LineStyle   = XLExcel.XlLineStyle.xlLineStyleNone;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideHorizontal].LineStyle = XLExcel.XlLineStyle.xlLineStyleNone;
            }

            //xlEdgeLeft
            if (xlEdgeLeft)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeLeft].LineStyle    = xlLineStyle;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeLeft].Weight       = xlWeight;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeLeft].ColorIndex   = 0;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeLeft].TintAndShade = 0;
            }
            //xlEdgeTop
            if (xlEdgeTop)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeTop].LineStyle    = xlLineStyle;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeTop].Weight       = xlWeight;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeTop].ColorIndex   = 0;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeTop].TintAndShade = 0;
            }
            //xlEdgeRight
            if (xlEdgeRight)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeRight].LineStyle    = xlLineStyle;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeRight].Weight       = xlWeight;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeRight].ColorIndex   = 0;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeRight].TintAndShade = 0;
            }
            //xlEdgeBottom
            if (xlEdgeBottom)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeBottom].LineStyle    = xlLineStyle;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeBottom].Weight       = xlWeight;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeBottom].ColorIndex   = 0;
                xlRange.Borders[XLExcel.XlBordersIndex.xlEdgeBottom].TintAndShade = 0;
            }
            //xlInsideVertical
            if (xlInsideVertical)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideVertical].LineStyle    = xlLineStyle;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideVertical].Weight       = xlWeight;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideVertical].ColorIndex   = 0;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideVertical].TintAndShade = 0;
            }
            //xlInsideHorizontal
            if (xlInsideHorizontal)
            {
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideHorizontal].LineStyle    = xlLineStyle;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideHorizontal].Weight       = xlWeight;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideHorizontal].ColorIndex   = 0;
                xlRange.Borders[XLExcel.XlBordersIndex.xlInsideHorizontal].TintAndShade = 0;
            }
            //xlDiagonalDown

            //xlDiagonalUp
        }
Beispiel #24
0
 public void SetBorders(Excel.XlLineStyle style)
 {
     this._range.Borders.LineStyle = style;
 }
Beispiel #25
0
 public void SetBorders(int startRow, int startCol, int endRow, int endCol, Excel.XlLineStyle style)
 {
     this.SetRange(startRow, startCol, endRow, endCol);
     this.SetBorders(style);
 }
Beispiel #26
0
 public void SetBottomBorder(int row, int col, Excel.XlLineStyle style)
 {
     this.SetRange(row, col);
     this.SetBottomBorder(style);
 }
Beispiel #27
0
 public void SetLeftBorder(Excel.XlLineStyle style)
 {
     this._leftBorder.LineStyle = style;
 }
Beispiel #28
0
 public void SetTopBorder(Excel.XlLineStyle style)
 {
     this._topBorder.LineStyle = style;
 }
Beispiel #29
0
        /// <summary>
        /// 绘制指定单元格的边框
        /// </summary>
        /// <param name="startRow">起始行</param>
        /// <param name="startColumn">起始列</param>
        /// <param name="endRow">结束行</param>
        /// <param name="endColumn">结束列</param>
        /// <param name="isDrawTop">是否画上外框</param>
        /// <param name="isDrawBottom">是否画下外框</param>
        /// <param name="isDrawLeft">是否画左外框</param>
        /// <param name="isDrawRight">是否画右外框</param>
        /// <param name="isDrawHInside">是否画水平内框</param>
        /// <param name="isDrawVInside">是否画垂直内框</param>
        /// <param name="isDrawDiagonalDown">是否画斜向下线</param>
        /// <param name="isDrawDiagonalUp">是否画斜向上线</param>
        /// <param name="lineStyle">线类型</param>
        /// <param name="borderWeight">线粗细</param>
        /// <param name="color">线颜色</param>
        public void CellsDrawFrame(int startRow, int startColumn, int endRow, int endColumn, bool isDrawTop, bool isDrawBottom, bool isDrawLeft,
                                   bool isDrawRight, bool isDrawHInside, bool isDrawVInside, bool isDrawDiagonalDown, bool isDrawDiagonalUp, Microsoft.Office.Interop.Excel.XlLineStyle lineStyle,
                                   Microsoft.Office.Interop.Excel.XlBorderWeight borderWeight, Microsoft.Office.Interop.Excel.XlColorIndex color)
        {
            //获取画边框的单元格
            Range range = m_pExcelApp.get_Range(m_pExcelApp.Cells[startRow, startColumn], m_pExcelApp.Cells[endRow, endColumn]);

            //清除所有边框

            //range.Borders[XlBordersIndex.xlEdgeTop].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlEdgeBottom].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlEdgeLeft].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlEdgeRight].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlInsideVertical].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlDiagonalDown].LineStyle = LineStyle.无;
            //range.Borders[XlBordersIndex.xlDiagonalUp].LineStyle = LineStyle.无;

            range.Borders[XlBordersIndex.xlEdgeTop].LineStyle          = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlEdgeBottom].LineStyle       = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlEdgeLeft].LineStyle         = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlEdgeRight].LineStyle        = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlInsideVertical].LineStyle   = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlDiagonalDown].LineStyle     = XlLineStyle.xlLineStyleNone;
            range.Borders[XlBordersIndex.xlDiagonalUp].LineStyle       = XlLineStyle.xlLineStyleNone;

            //以下是按参数画边框
            if (isDrawTop)
            {
                range.Borders[XlBordersIndex.xlEdgeTop].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlEdgeTop].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlEdgeTop].ColorIndex = color;
            }

            if (isDrawBottom)
            {
                range.Borders[XlBordersIndex.xlEdgeBottom].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlEdgeBottom].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlEdgeBottom].ColorIndex = color;
            }

            if (isDrawLeft)
            {
                range.Borders[XlBordersIndex.xlEdgeLeft].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlEdgeLeft].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlEdgeLeft].ColorIndex = color;
            }

            if (isDrawRight)
            {
                range.Borders[XlBordersIndex.xlEdgeRight].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlEdgeRight].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlEdgeRight].ColorIndex = color;
            }

            if (isDrawVInside)
            {
                range.Borders[XlBordersIndex.xlInsideVertical].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlInsideVertical].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlInsideVertical].ColorIndex = color;
            }

            if (isDrawHInside)
            {
                range.Borders[XlBordersIndex.xlInsideHorizontal].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlInsideHorizontal].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlInsideHorizontal].ColorIndex = color;
            }

            if (isDrawDiagonalDown)
            {
                range.Borders[XlBordersIndex.xlDiagonalDown].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlDiagonalDown].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlDiagonalDown].ColorIndex = color;
            }

            if (isDrawDiagonalUp)
            {
                range.Borders[XlBordersIndex.xlDiagonalUp].LineStyle  = lineStyle;
                range.Borders[XlBordersIndex.xlDiagonalUp].Weight     = borderWeight;
                range.Borders[XlBordersIndex.xlDiagonalUp].ColorIndex = color;
            }
            Marshal.ReleaseComObject(range);
        }
Beispiel #30
0
 public void SetBottomBorder(Excel.XlLineStyle style)
 {
     this._bottomBorder.LineStyle = style;
 }