Esempio n. 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);
 }
Esempio n. 2
0
 /// <summary>
 /// Imposta tutti i bordi allo stile da applicare al range.
 /// </summary>
 /// <param name="s">Stile.</param>
 /// <param name="colorIndex">Colore del bordo.</param>
 /// <param name="weight">Spessore del bordo.</param>
 public static void SetAllBorders(Excel.Style s, int colorIndex, Excel.XlBorderWeight weight)
 {
     s.Borders.ColorIndex = colorIndex;
     s.Borders.Weight     = weight;
     s.Borders[Excel.XlBordersIndex.xlDiagonalDown].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
     s.Borders[Excel.XlBordersIndex.xlDiagonalUp].LineStyle   = Excel.XlLineStyle.xlLineStyleNone;
 }
Esempio n. 3
0
        /// <summary>
        /// DrawGrid
        /// </summary>
        /// <param name="point_a"></param>
        /// <param name="point_b"></param>
        /// <param name="weight"></param>
        /// <param name="line_color"></param>
        public void DrawGrid(string point_a, string point_b, Excel.XlBorderWeight weight = Excel.XlBorderWeight.xlThin, Color?line_color = null)
        {
            Color line_rgb = line_color ?? Color.FromArgb(0, 0, 0);

            sheet1.Range[point_a, point_b].Cells.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
            sheet1.Range[point_a, point_b].Borders.Color           = ColorTranslator.ToOle(line_rgb);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public static void RangeBorder(dynamic Range, Excel.XlBorderWeight border = Excel.XlBorderWeight.xlThin)
 {
     Range.Borders[Excel.XlBordersIndex.xlEdgeTop].Weight          = border;
     Range.Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight         = border;
     Range.Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight       = border;
     Range.Borders[Excel.XlBordersIndex.xlEdgeRight].Weight        = border;
     Range.Borders[Excel.XlBordersIndex.xlInsideHorizontal].Weight = border;
     Range.Borders[Excel.XlBordersIndex.xlInsideVertical].Weight   = border;
 }
 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;
 }
Esempio n. 7
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;
            }
        }
Esempio n. 8
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
        }
Esempio n. 9
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é.");
            }
        }
Esempio n. 10
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)
            {
            }
        }
Esempio n. 11
0
        //  EXPORT GARDE CORPS
        public static void exportgardecorps(Excel.Application xlapp, Excel.Workbook workbook, Dictionary <string, double> gardecorps, Dictionary <int, string> erreursgc)
        {
            object misvalue = System.Reflection.Missing.Value;

            Excel.Worksheet worksheet3 = workbook.Sheets.Add(misvalue, workbook.Sheets.Item[2]);
            worksheet3.Columns.ColumnWidth = 25;
            worksheet3.Name = "Garde-Corps";
            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.XlVAlign       centre    = Excel.XlVAlign.xlVAlignCenter;
            Excel.XlRgbColor     rouge     = Excel.XlRgbColor.rgbRed;
            Excel.XlRgbColor     gold      = Excel.XlRgbColor.rgbGold;
            Excel.XlRgbColor     vert      = Excel.XlRgbColor.rgbLightGreen;
            Excel.XlRgbColor     gris      = Excel.XlRgbColor.rgbLightGrey;

            if (gardecorps.Count != 0)
            {
                Excel.Range rangetitre1 = worksheet3.Range["A1", "C1"];
                rangetitre1.Merge();
                rangetitre1.Value             = "GARDE-CORPS";
                rangetitre1.Font.Bold         = true;
                rangetitre1.Font.Color        = rouge;
                rangetitre1.Font.Size         = 14;
                rangetitre1.VerticalAlignment = centre;

                worksheet3.Range["A3"].Value = "Nombre de type de garde corps";
                worksheet3.Range["A3", "A4"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A3", "A4"].Interior.Color = vert;

                worksheet3.Range["A6"].Value = "Liste des type de garde corps";
                worksheet3.Range["A6", "B6"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["A6", "B6"].Interior.Color = gold;

                worksheet3.Range["B6"].Value = "métré (en m)";

                worksheet3.Range["B3"].Value = "métré total (en m)";
                worksheet3.Range["B3", "B4"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["B3", "B4"].Interior.Color = vert;

                worksheet3.Range["D5"].Value = "ERREURS DE MODELISATION";
                worksheet3.Range["D5"].BorderAround2(lcontinue, llarge);
                worksheet3.Range["D5"].Interior.Color = gold;
                worksheet3.Range["D6"].Value          = "ID du type de garde-corps";
                worksheet3.Range["D6"].Interior.Color = gold;
                worksheet3.Range["E6"].Value          = "Type du garde corps";
                worksheet3.Range["E6"].Interior.Color = gold;
                worksheet3.Range["D6", "E6"].BorderAround2(lcontinue, llarge);

                int    i          = 6;
                double sommemetre = 0;
                worksheet3.Cells[4, 1] = gardecorps.Count;
                foreach (string garde in gardecorps.Keys)
                {
                    i += 1;
                    Excel.Range nomgarde = worksheet3.Cells[i, 1];
                    nomgarde.Value = garde;
                    nomgarde.BorderAround2(lcontinue, lfin);
                    Excel.Range metregarde = worksheet3.Cells[i, 2];
                    metregarde.Value = gardecorps[garde];
                    metregarde.BorderAround2(lcontinue, lfin);
                    sommemetre += gardecorps[garde];
                    if (i % 2 == 0)
                    {
                        nomgarde.Interior.Color   = gris;
                        metregarde.Interior.Color = gris;
                    }
                }
                worksheet3.Range["B4"].Value = sommemetre;
                string      gardeBD     = "B" + i.ToString();
                string      gardeBG     = "A" + i.ToString();
                Excel.Range rangegardeD = worksheet3.Range["B7", gardeBD];
                Excel.Range rangegardeB = worksheet3.Range[gardeBG, gardeBD];
                rangegardeB.Borders[lbas].LineStyle    = lcontinue;
                rangegardeB.Borders[lbas].Weight       = llarge;
                rangegardeD.Borders[ldroite].LineStyle = lcontinue;
                rangegardeD.Borders[ldroite].Weight    = llarge;
            }
            else if (gardecorps.Count == 0)
            {
                revitui.TaskDialog.Show("Erreur", "Aucun garde-corps correctement modélisé");
            }
            if (erreursgc.Count != 0)
            {
                int j = 6;
                foreach (int gardeid in erreursgc.Keys)
                {
                    j += 1;
                    Excel.Range cellid = worksheet3.Cells[j, 4];
                    cellid.Value = gardeid;
                    cellid.BorderAround2(lcontinue, lfin);
                    Excel.Range cellerr = worksheet3.Cells[j, 5];
                    cellerr.Value = erreursgc[gardeid];
                    cellerr.BorderAround2(lcontinue, lfin);
                    if (j % 2 == 0)
                    {
                        cellid.Interior.Color  = gris;
                        cellerr.Interior.Color = gris;
                    }
                }
                string      erreurB  = "D" + j.ToString();
                string      erreurBD = "E" + j.ToString();
                Excel.Range lgarderr = worksheet3.Range["D7", erreurB];
                Excel.Range rangeD   = worksheet3.Range["E7", erreurBD];
                rangeD.Borders[ldroite].LineStyle   = lcontinue;
                rangeD.Borders[ldroite].Weight      = llarge;
                lgarderr.Borders[lgauche].LineStyle = lcontinue;
                lgarderr.Borders[lgauche].Weight    = llarge;
                worksheet3.Range[erreurB, erreurBD].Borders[lbas].Weight = llarge;
            }
            else if (gardecorps.Count == 0 & erreursgc.Count == 0)
            {
                revitui.TaskDialog.Show("Aucun garde-corps modélisé", "L'export des garde-corps vers Excel ne sera pas réalisé.");
            }
        }
Esempio n. 12
0
 public void SetBorderAroundInRange(string range, ExcelFile.XlLineStyle lineStyle, ExcelFile.XlBorderWeight weight, ExcelFile.XlColorIndex colorIndex)
 {
     _excel.get_Range(range).BorderAround(lineStyle, weight, colorIndex);
 }
Esempio n. 13
0
 /// <summary>
 /// Toggles a border of the specified cells and applies the settings if it is toggled on.
 /// </summary>
 /// <param name="cellSelection">Indicates the cells to be changed.  Works just like Excel.  Example: "A:A,1:1,A2:B3,F4,F5"</param>
 /// <param name="borderToToggle">Indicates the border that will be toggled.</param>
 /// <param name="weightToSet">Indicates the weight the border will be set to if it is being toggled on.</param>
 /// <param name="styleToSet">Indicates the line style the border will be set to if it is being toggled on.</param>
 public void SetBorders(string cellSelection, XlBordersIndex bordersToToggle, Microsoft.Office.Interop.Excel.XlBorderWeight weightToSet, XlLineStyle styleToSet)
 {
     SetBorders(ReportGlobals.defaultWorkbookName, ReportGlobals.defaultSheetIndex, cellSelection, bordersToToggle, weightToSet, styleToSet);
 }
Esempio n. 14
0
 private void drawLine(Microsoft.Office.Interop.Excel.Application app, Microsoft.Office.Interop.Excel.XlBordersIndex idxEdge, Microsoft.Office.Interop.Excel.XlBorderWeight borderweight)
 {
     app.Selection.Borders(idxEdge).LineStyle    = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
     app.Selection.Borders(idxEdge).ColorIndex   = 0;
     app.Selection.Borders(idxEdge).TintAndShade = 0;
     app.Selection.Borders(idxEdge).Weight       = borderweight;
 }
Esempio n. 15
0
        /// <summary>
        /// Applica tutte le proprietà di stile definite per le applicazioni al range rng.
        /// </summary>
        /// <param name="rng">Range a cui applicare gli stili.</param>
        /// <param name="fontName">Stringa rappresentante il nome del font (i.e. Verdana).</param>
        /// <param name="style">Stringa rappresentante il nome di uno stile predefinito (i.e. Normale).</param>
        /// <param name="merge">Booleano che indica se il range deve essere unito o no.</param>
        /// <param name="bold">Booleano che indica se il font deve essere in grassetto o no.</param>
        /// <param name="fontSize">Intero che indica la dimensione testo.</param>
        /// <param name="align">Oggetto Microsoft.Office.Interop.Excel.XlHAlign per definire il tipo di allineamento orizzontale del range.</param>
        /// <param name="numberFormat">Stringa rappresentante il formato numero della cella.</param>
        /// <param name="foreColor">ColorIndex rappresentante il colore del testo della cella.</param>
        /// <param name="backColor">ColorIndex rappresentante il colore dello sfondo della cella.</param>
        /// <param name="pattern">Oggetto Microsoft.Office.Interop.Excel.XlPattern per definire il tipo di pattern da applicare allo sfondo della cella.</param>
        /// <param name="borders">Stringa che definisce quali bordi e con che spessore debbano essere disegnati. La stringa è nel formato [Top|Left|Bottom|Right|InsideH|InsideV = Thick|Thin|Medium|Hairline, ...].</param>
        /// <param name="orientation">Oggetto Microsoft.Office.Interop.Excel.XlOrientation che definisce che orientazione deve avere il testo del range</param>
        /// <param name="visible">Booleano che indica se il range deve essere visibile oppure no.</param>
        public static void RangeStyle(Excel.Range rng, object fontName = null, object style = null, object merge = null, object bold = null, object fontSize = null, object align = null, object numberFormat = null, object foreColor = null, object backColor = null, object pattern = null, object borders = null, object orientation = null, object visible = null)
        {
            //applica stile per prima cosa
            if (style != null)
            {
                rng.Style = (string)style;
            }

            //Font
            if (fontName != null)
            {
                rng.Font.Name = (string)fontName;
            }

            if (bold != null)
            {
                rng.Font.Bold = (bool)bold;
            }

            if (fontSize != null)
            {
                rng.Font.Size = (int)fontSize;
            }

            if (foreColor != null)
            {
                rng.Font.ColorIndex = (int)foreColor;
            }
            //end Font

            if (merge != null)
            {
                rng.MergeCells = (bool)merge;
            }

            if (align != null)
            {
                rng.HorizontalAlignment = (Excel.XlHAlign)align;
                rng.VerticalAlignment   = Excel.XlVAlign.xlVAlignCenter;
            }

            if (numberFormat != null)
            {
                rng.NumberFormat = (string)numberFormat;
            }

            if (pattern != null)
            {
                rng.Interior.Pattern = (Excel.XlPattern)pattern;
            }

            if (backColor != null)
            {
                rng.Interior.ColorIndex = (int)backColor;
            }

            if (orientation != null)
            {
                rng.Orientation = (Excel.XlOrientation)orientation;
            }

            if (visible != null)
            {
                rng.EntireRow.Hidden = !(bool)visible;
            }

            if (borders != null)
            {
                MatchCollection borderString = Regex.Matches((string)borders, @"(Top|Left|Bottom|Right|InsideH|InsideV)([:=]\w*)?", RegexOptions.IgnoreCase);
                foreach (Match border in borderString)
                {
                    string[] b = Regex.Split(border.Value, @"\s*[:=]\s*");

                    Excel.XlBordersIndex index  = Excel.XlBordersIndex.xlEdgeTop;
                    Excel.XlBorderWeight weight = Excel.XlBorderWeight.xlThin;
                    switch (b[0].ToLowerInvariant())
                    {
                    case "top":
                        index = Excel.XlBordersIndex.xlEdgeTop;
                        break;

                    case "left":
                        index = Excel.XlBordersIndex.xlEdgeLeft;
                        break;

                    case "bottom":
                        index = Excel.XlBordersIndex.xlEdgeBottom;
                        break;

                    case "right":
                        index = Excel.XlBordersIndex.xlEdgeRight;
                        break;

                    case "insideh":
                        index = Excel.XlBordersIndex.xlInsideHorizontal;
                        break;

                    case "insidev":
                        index = Excel.XlBordersIndex.xlInsideVertical;
                        break;
                    }
                    if (b.Length == 2)
                    {
                        switch (b[1].ToLowerInvariant())
                        {
                        case "thick":
                            weight = Excel.XlBorderWeight.xlThick;
                            break;

                        case "thin":
                            weight = Excel.XlBorderWeight.xlThin;
                            break;

                        case "medium":
                            weight = Excel.XlBorderWeight.xlMedium;
                            break;

                        case "hairline":
                            weight = Excel.XlBorderWeight.xlHairline;
                            break;
                        }
                    }
                    rng.Borders[index].LineStyle = Excel.XlLineStyle.xlContinuous;
                    rng.Borders[index].Weight    = weight;
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// DrawCellBorder
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <param name="weight"></param>
        /// <param name="line_color"></param>
        /// <param name="line"></param>
        public void DrawCellBorder(int row, string col, Excel.XlBorderWeight weight = Excel.XlBorderWeight.xlThin, Color?line_color = null, Excel.XlLineStyle line = Excel.XlLineStyle.xlContinuous)
        {
            Color line_rgb = line_color ?? Color.FromArgb(0, 0, 0);

            sheet1.Cells[row, col].BorderAround(line, weight, Color: line_rgb);
        }
Esempio n. 17
0
 public static void DrawBorders(Excel.Worksheet oSheet, int row1, int col1, int row2, int col2, Excel.XlLineStyle line, Excel.XlBorderWeight weight)
 {
     Excel.Range rg = oSheet.get_Range(GetColumnName(col1) + row1, GetColumnName(col2) + row2);
     DrawBorders(rg, line, weight);
 }
Esempio n. 18
0
 /// <summary>
 /// Chn 设置边框样式
 /// </summary>
 /// <param name="workSheet"></param>
 /// <param name="range"></param>
 /// <param name="lineStyle"></param>
 /// <param name="weight"></param>
 public static void SetBorder(this Excel.Worksheet workSheet, Excel.Range range, Excel.XlLineStyle lineStyle, Excel.XlBorderWeight weight, ExcelColorIndex?borderColor)
 {
     range.Borders.LineStyle = lineStyle;
     range.Borders.Weight    = weight;
     if (borderColor != null)
     {
         range.Borders.ColorIndex = borderColor;
     }
 }
Esempio n. 19
0
 public ExcelBorder(Excel.XlLineStyle lineStyle, Excel.XlBorderWeight weight, ExcelColorIndex?borderColor)
 {
     LineStyle   = lineStyle;
     Weight      = weight;
     BorderColor = borderColor;
 }
Esempio n. 20
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;
        }
Esempio n. 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
        }
Esempio n. 22
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;
 }
Esempio n. 23
0
        /// <summary>
        /// Toggles a border of the specified cells and applies the settings if it is toggled on.
        /// </summary>
        /// <param name="workbookName">The stored index of the workbook.</param>
        /// <param name="sheetIndex">The sheet number you wish to alter (note: excel sheets begin with number 1, not 0).</param>
        /// <param name="cellSelection">Indicates the cells to be changed.  Works just like Excel.  Example: "A:A,1:1,A2:B3,F4,F5"</param>
        /// <param name="borderToToggle">Indicates the border that will be toggled.</param>
        /// <param name="weightToSet">Indicates the weight the border will be set to if it is being toggled on.</param>
        /// <param name="styleToSet">Indicates the line style the border will be set to if it is being toggled on.</param>
        public void SetBorders(string workbookName, int sheetIndex, string cellSelection, XlBordersIndex borderToToggle, Microsoft.Office.Interop.Excel.XlBorderWeight weightToSet, XlLineStyle styleToSet)
        {
            List <Range> rangesToAlter = GetRanges(workbookName, sheetIndex, cellSelection);

            foreach (Range rangeToAlter in rangesToAlter)
            {
                if ((XlLineStyle)rangeToAlter.Borders[borderToToggle].LineStyle != XlLineStyle.xlLineStyleNone)
                {
                    rangeToAlter.Borders[borderToToggle].LineStyle = XlLineStyle.xlLineStyleNone;
                }
                else
                {
                    rangeToAlter.Borders[borderToToggle].LineStyle = styleToSet;
                    rangeToAlter.Borders[borderToToggle].Weight    = weightToSet;
                }
            }
        }
Esempio n. 24
0
        /// <summary>
        /// DrawBorder
        /// </summary>
        /// <param name="point_a"></param>
        /// <param name="point_b"></param>
        /// <param name="weight"></param>
        /// <param name="line_color"></param>
        /// <param name="line"></param>
        public void DrawBorder(string point_a, string point_b, Excel.XlBorderWeight weight = Excel.XlBorderWeight.xlThin, Color?line_color = null, Excel.XlLineStyle line = Excel.XlLineStyle.xlContinuous)
        {
            Color line_rgb = line_color ?? Color.FromArgb(0, 0, 0);

            sheet1.Range[point_a, point_b].BorderAround(line, weight, Color: line_rgb);
        }
Esempio n. 25
0
 //УСТАНОВКА ВИДА ГРАНИЦ
 public void SetBorderStyle(int color, Excel.XlLineStyle lineStyle, Excel.XlBorderWeight weight)
 {
     _range.Borders.ColorIndex = color;
     _range.Borders.LineStyle  = lineStyle;
     _range.Borders.Weight     = weight;
 }
Esempio n. 26
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 {}
        }
Esempio n. 27
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;
 }
Esempio n. 28
0
        //EXPORT APPARTEMENT
        public static void Exporttypoappart(Excel.Application xlapp, Excel.Workbook workbook, Dictionary <string, string> listappart, Dictionary <string, double> areaappart, Dictionary <string, List <double> > listtypo, Dictionary <string, double> autrepieces)
        {
            object misvalue = System.Reflection.Missing.Value;

            Excel.Worksheet worksheet1 = workbook.Sheets[1];
            worksheet1.Columns.ColumnWidth = 25;
            worksheet1.Name = "Logements";
            if (listappart.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.XlVAlign       centre    = Excel.XlVAlign.xlVAlignCenter;
                Excel.XlVAlign       justi     = Excel.XlVAlign.xlVAlignJustify;
                Excel.XlRgbColor     rouge     = Excel.XlRgbColor.rgbRed;
                Excel.XlRgbColor     gold      = Excel.XlRgbColor.rgbGold;
                Excel.XlRgbColor     vert      = Excel.XlRgbColor.rgbLightGreen;
                Excel.XlRgbColor     gris      = Excel.XlRgbColor.rgbLightGrey;

                Excel.Range rangetitre1 = worksheet1.Range["A1"];
                rangetitre1.Value             = "INDICATEUR LOGEMENT";
                rangetitre1.Font.Bold         = true;
                rangetitre1.Font.Color        = rouge;
                rangetitre1.Font.Size         = 14;
                rangetitre1.VerticalAlignment = justi;
                rangetitre1.VerticalAlignment = centre;

                Excel.Range rangetitre2 = worksheet1.Range["A3"];
                rangetitre2.Value = "Nombre de logement total :";
                worksheet1.Range["A3", "B3"].BorderAround2(lcontinue, llarge);
                worksheet1.Range["A3", "B3"].Interior.Color = vert;

                Excel.Range nombrelogement = worksheet1.Range["B3"];
                nombrelogement.Value = listappart.Count;

                Excel.Range rangetypo = worksheet1.Range["A4"];
                rangetypo.Value = "Typologie";
                rangetypo.BorderAround2(lcontinue, llarge);
                rangetypo.Interior.Color = gold;
                rangetypo.Font.Bold      = true;

                Excel.Range rangenbrappart = worksheet1.Range["A5"];
                rangenbrappart.Value = "nombre de type de logement";
                rangenbrappart.BorderAround2(lcontinue, llarge);
                rangenbrappart.Interior.Color = gold;
                rangenbrappart.Font.Bold      = true;

                Excel.Range rangemoy = worksheet1.Range["A6"];
                rangemoy.Value = "Surface moyenne du type";
                rangemoy.BorderAround2(lcontinue, llarge);
                rangemoy.Interior.Color = gold;
                rangemoy.Font.Bold      = true;

                Excel.Range rangetitre3 = worksheet1.Range["H8", "I8"];
                rangetitre3.BorderAround2(lcontinue, llarge);
                rangetitre3.Value          = "Nombre de pièces communes";
                worksheet1.Cells[8, 9]     = autrepieces.Count;
                rangetitre3.Interior.Color = vert;


                Excel.Range rangetitre4 = worksheet1.Range["H9"];
                rangetitre4.BorderAround2(lcontinue, llarge);
                rangetitre4.Value             = "Pièces communes";
                rangetitre4.Font.Bold         = true;
                rangetitre4.VerticalAlignment = centre;
                rangetitre4.Interior.Color    = gold;

                Excel.Range rangetitreC = worksheet1.Range["I9"];
                rangetitreC.BorderAround2(lcontinue, llarge);
                rangetitreC.Value             = "Surface (m²)";
                rangetitreC.Font.Bold         = true;
                rangetitreC.VerticalAlignment = centre;
                rangetitreC.Interior.Color    = gold;

                Excel.Range rangetitre5 = worksheet1.Range["A9"];
                rangetitre5.BorderAround2(lcontinue, llarge);
                rangetitre5.Value             = "Appartements";
                rangetitre5.Font.Bold         = true;
                rangetitre5.VerticalAlignment = centre;
                rangetitre5.Interior.Color    = gold;

                Excel.Range rangetitre6 = worksheet1.Range["B9"];
                rangetitre6.BorderAround2(lcontinue, llarge);
                rangetitre6.Value             = "Typologies";
                rangetitre6.Font.Bold         = true;
                rangetitre6.VerticalAlignment = centre;
                rangetitre6.Interior.Color    = gold;

                Excel.Range rangetitre7 = worksheet1.Range["C9"];
                rangetitre7.BorderAround2(lcontinue, llarge);
                rangetitre7.Value             = "Surfaces (m²)";
                rangetitre7.Font.Bold         = true;
                rangetitre7.VerticalAlignment = centre;
                rangetitre7.Interior.Color    = gold;

                int i = 9;
                foreach (string appart in listappart.Keys)
                {
                    i += 1;
                    Excel.Range nomappartcell = worksheet1.Cells[i, 1];
                    nomappartcell.Value = appart;
                    Excel.Range typapartcell = worksheet1.Cells[i, 2];
                    typapartcell.Value = listappart[appart];
                    double surfaceappart = areaappart[appart];
                    surfaceappart = Math.Round(surfaceappart, 2);
                    Excel.Range surfappartcell = worksheet1.Cells[i, 3];
                    surfappartcell.Value = surfaceappart;
                    if (i % 2 == 0)
                    {
                        nomappartcell.Interior.Color  = gris;
                        typapartcell.Interior.Color   = gris;
                        surfappartcell.Interior.Color = gris;
                    }
                }
                string      pBG      = "A" + i.ToString();
                string      pBD      = "C" + i.ToString();
                Excel.Range rangeA   = worksheet1.Range["A10", pBG];
                Excel.Range rangeB   = worksheet1.Range["C10", pBD];
                Excel.Range rangefin = worksheet1.Range[pBG, pBD];
                rangeA.Borders[lgauche].LineStyle   = lcontinue;
                rangeA.Borders[lgauche].Weight      = llarge;
                rangeB.Borders[ldroite].LineStyle   = lcontinue;
                rangeB.Borders[ldroite].Weight      = llarge;
                rangefin.Borders[ldroite].LineStyle = lcontinue;
                rangefin.Borders[lbas].Weight       = llarge;

                int j = 1;
                foreach (string typo in listtypo.Keys)
                {
                    j += 1;
                    Excel.Range typocell = worksheet1.Cells[4, j];
                    typocell.Value          = typo;
                    typocell.Interior.Color = gris;
                    typocell.BorderAround2(lcontinue, lfin);
                    typocell.Borders[ldroite].Weight = llarge;
                    typocell.Borders[lgauche].Weight = llarge;
                    Excel.Range nbrtypocell = worksheet1.Cells[5, j];
                    nbrtypocell.Value = listtypo[typo][0];
                    nbrtypocell.BorderAround2(lcontinue, lfin);
                    nbrtypocell.Borders[ldroite].Weight = llarge;
                    nbrtypocell.Borders[lgauche].Weight = llarge;
                    double moyennetypo = listtypo[typo][1];
                    moyennetypo = Math.Round(moyennetypo, 2);
                    Excel.Range moytypocell = worksheet1.Cells[6, j];
                    moytypocell.Value          = moyennetypo;
                    moytypocell.Interior.Color = gris;
                    moytypocell.BorderAround2(lcontinue, lfin);
                    moytypocell.Borders[ldroite].Weight = llarge;
                    moytypocell.Borders[lgauche].Weight = llarge;
                }
                Excel.Range cell          = worksheet1.Cells[4, j];
                Excel.Range cell2         = worksheet1.Cells[6, j];
                Excel.Range rangetypohaut = worksheet1.Range["B4", cell];
                Excel.Range rangetypobas  = worksheet1.Range["B6", cell2];
                Excel.Range rangetypD     = worksheet1.Range[cell, cell2];
                rangetypohaut.Borders[lhaut].LineStyle = lcontinue;
                rangetypohaut.Borders[lhaut].Weight    = llarge;
                rangetypobas.Borders[lbas].LineStyle   = lcontinue;
                rangetypobas.Borders[lbas].Weight      = llarge;
                rangetypD.Borders[ldroite].LineStyle   = lcontinue;
                rangetypD.Borders[ldroite].Weight      = llarge;

                int k = 9;
                foreach (string piece in autrepieces.Keys)
                {
                    k += 1;
                    Excel.Range piececell = worksheet1.Cells[k, 8];
                    piececell.Value = piece;
                    Excel.Range autrecell = worksheet1.Cells[k, 9];
                    autrecell.Value = autrepieces[piece];
                    if (k % 2 == 0)
                    {
                        piececell.Interior.Color = gris;
                        autrecell.Interior.Color = gris;
                    }
                }
                string      communBG  = "H" + k.ToString();
                string      communBD  = "I" + k.ToString();
                Excel.Range rangecomg = worksheet1.Range["H10", communBG];
                Excel.Range rangecomd = worksheet1.Range["I10", communBD];
                Excel.Range rangecomb = worksheet1.Range[communBG, communBD];
                rangecomg.Borders[lgauche].LineStyle = lcontinue;
                rangecomg.Borders[lgauche].Weight    = llarge;
                rangecomd.Borders[ldroite].LineStyle = lcontinue;
                rangecomd.Borders[ldroite].Weight    = llarge;
                rangecomb.Borders[lbas].LineStyle    = lcontinue;
                rangecomb.Borders[lbas].Weight       = llarge;
            }
            else
            {
                revitui.TaskDialog.Show("Aucun appartement", "Aucun appartement trouvé. L'export des appartements vers Excel ne sera pas réalisé");
            }
        }
Esempio n. 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);
        }
Esempio n. 30
0
        // EXPORT PARKINGS
        public static void exportparking(Excel.Application xlapp, Excel.Workbook workbook, Dictionary <string, int> parkings, int sommeplace)
        {
            object misvalue = System.Reflection.Missing.Value;

            Excel.Worksheet worksheet2 = workbook.Sheets.Add(misvalue, workbook.Sheets.Item[1]);
            worksheet2.Columns.ColumnWidth = 25;
            worksheet2.Name = "Parking";
            if (parkings.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.XlVAlign       centre     = Excel.XlVAlign.xlVAlignCenter;
                Excel.XlRgbColor     rouge      = Excel.XlRgbColor.rgbRed;
                Excel.XlRgbColor     sofyacolor = Excel.XlRgbColor.rgbGold;
                Excel.XlRgbColor     vert       = Excel.XlRgbColor.rgbLightGreen;
                Excel.XlRgbColor     gris       = Excel.XlRgbColor.rgbLightGrey;

                Excel.Range rangetitre1 = worksheet2.Range["A1", "C1"];
                rangetitre1.Merge();
                rangetitre1.Font.Bold         = true;
                rangetitre1.Font.Size         = 14;
                rangetitre1.Font.Color        = rouge;
                rangetitre1.Value             = "PARKINGS";
                rangetitre1.VerticalAlignment = centre;

                worksheet2.Range["A4"].Value = "Type de place de parking";
                worksheet2.Range["A4"].BorderAround2(lcontinue, llarge);
                worksheet2.Range["A4"].Interior.Color = sofyacolor;

                worksheet2.Range["B4"].Value = "Nombre de place du type";
                worksheet2.Range["B4"].BorderAround2(lcontinue, llarge);
                worksheet2.Range["B4"].Interior.Color = sofyacolor;

                worksheet2.Range["C4"].Value = "Pourcentage (%)";
                worksheet2.Range["C4"].BorderAround2(lcontinue, llarge);
                worksheet2.Range["C4"].Interior.Color = sofyacolor;
                try
                {
                    int i = 4;
                    foreach (string park in parkings.Keys)
                    {
                        i += 1;
                        Excel.Range nompark = worksheet2.Cells[i, 1];
                        nompark.Value = park;
                        nompark.BorderAround2(lcontinue, lfin);
                        Excel.Range nbrparking = worksheet2.Cells[i, 2];
                        nbrparking.Value = parkings[park];
                        nbrparking.BorderAround2(lcontinue, lfin);
                        double parc     = parkings[park];
                        double somme    = sommeplace;
                        double pourcent = (parc / somme) * 100;
                        pourcent = Math.Round(pourcent, 2);
                        Excel.Range ratiocell = worksheet2.Cells[i, 3];
                        ratiocell.Value = pourcent;
                        ratiocell.BorderAround2(lcontinue, lfin);
                        if (i % 2 == (0))
                        {
                            nompark.Interior.Color    = gris;
                            nbrparking.Interior.Color = gris;
                            ratiocell.Interior.Color  = gris;
                        }
                    }
                    string      parkBG     = "A" + i.ToString();
                    string      parkBD     = "C" + i.ToString();
                    Excel.Range rangeparkD = worksheet2.Range["C4", parkBD];
                    Excel.Range rangeparkB = worksheet2.Range[parkBG, parkBD];
                    rangeparkD.Borders[ldroite].LineStyle = lcontinue;
                    rangeparkD.Borders[ldroite].Weight    = llarge;
                    rangeparkB.Borders[lbas].LineStyle    = lcontinue;
                    rangeparkB.Borders[lbas].Weight       = llarge;
                    //Total place
                    worksheet2.Range["A3"].Value = "Total :";
                    worksheet2.Range["B3"].Value = sommeplace;
                    worksheet2.Range["A3", "B3"].BorderAround2(lcontinue, llarge);
                    worksheet2.Range["A3", "B3"].Interior.Color = vert;
                }

                catch
                {
                    revitui.TaskDialog.Show("Erreur", "Erreur lors de l'export Excel des parkings");
                }
            }
            else
            {
                revitui.TaskDialog.Show("Aucune place de parking modélisée", "L'export des places de parkings vers Excel ne sera pas réalisé.");
            }
        }