//Creation d'une ligne en mode monoSheet
        public Row creerLigne2(DataRow dr, int index, uint[] style)
        {
            Row r = new Row()
            {
                RowIndex = (uint)index
            };
            Cell c = new Cell();
            int  i = 0;

            foreach (var att in dr.ItemArray)
            {
                c = new Cell();

                try { c = XcelWin.createCellDouble(headerColumns[i], index, Convert.ToDouble(att), style[0]); }
                catch (Exception) { string tmp; if (att == DBNull.Value)
                                    {
                                        tmp = "";
                                    }
                                    else
                                    {
                                        tmp = att.ToString();
                                    } c = XcelWin.createTextCell(headerColumns[i], index, tmp, style[0]); }

                r.AppendChild(c);
                i++;
            }

            return(r);
        }
        //Remplissage de la feuille en mode monoSheet
        public SheetData creerFeuille2(WorksheetPart worksheetPart, DataSet ds)
        {
            SheetData sd    = worksheetPart.Worksheet.GetFirstChild <SheetData>();
            int       index = 1;

            foreach (DataTable dt in ds.Tables)
            {
                Row r = new Row();
                if (!dt.Columns[0].ColumnName.Contains("Column"))
                {
                    r = XcelWin.creerTitres(dt, index);
                    sd.AppendChild(r);
                    index++;
                }

                r = new Row();
                foreach (DataRow item in dt.Rows)
                {
                    uint[] a = { 0, 0, 0, 0, 0, 0 };
                    r = creerLigne2(item, index, a);
                    sd.AppendChild(r);
                    index++;
                }
                index++;
            }
            return(sd);
        }
        public static Row creerLigne(DataRow dr, int index, uint style, int nbColonneConfig)
        {
            Row  r = new Row();
            Cell c = new Cell();
            int  i = 0;

            foreach (var att in dr.ItemArray.Skip(nbColonneConfig))
            {
                c = new Cell();

                try { c = XcelWin.createTextCell(Ultimate.headerColumns[i], index, Convert.ToDateTime(att).ToShortDateString(), style); }
                catch (Exception)
                {
                    try { c = XcelWin.createCellFloat(Ultimate.headerColumns[i], index, Convert.ToSingle(att), style); }
                    catch (Exception) { string tmp; if (att == DBNull.Value)
                                        {
                                            tmp = "";
                                        }
                                        else
                                        {
                                            tmp = att.ToString();
                                        } c = XcelWin.createTextCell(Ultimate.headerColumns[i], index, tmp, style); }
                }

                r.AppendChild(c);
                i++;
            }

            return(r);
        }
        //inuilisé mais peut etre pour les metacharts avec des séries de types diférent
        public void aiguillageSeriesParType(ChartPart cp, List <string> formules, List <string> typesSeries)
        {
            if (typesSeries.Count == (formules.Count - 1) / 2)
            {
                List <int> auto = new List <int>();
                for (int i = 0; i < typesSeries.Count; i++)
                {
                    if (typesSeries[i] == "")
                    {
                        auto.Add(i);
                    }
                }

                List <string> formuleAuto = new List <string>()
                {
                    formules[0]
                };
                foreach (int i in auto)
                {
                    formuleAuto.Add(formules[2 * i + 1]);
                    formuleAuto.Add(formules[2 * i + 2]);
                }
                XcelWin.majMetaChart(cp, formules);
            }
            else
            {
                Console.WriteLine("Erreure Inconnue, fonction aiguillageSeriesParType");
            }
        }
        public static uint creerStyle(Stylesheet ss, string police, int taille, bool bold, string fontColor,
                                      string fillColor, string ts, string bs, string ls, string rs, uint numberFormat)
        {
            uint f  = XcelWin.ajoutFont(ss, police, taille, bold, fontColor);
            uint f2 = XcelWin.ajoutFill(ss, fillColor);
            uint b  = XcelWin.ajoutBorder(ss, ts, bs, ls, rs);
            uint c  = XcelWin.ajouterCellformat(ss, numberFormat, f, f2, b, 0);

            return(c);
        }
        public void creerTableau(WorksheetPart worksheetPart, DataTable dt, int indice)
        {
            obtentionBornesColonnes(dt);

            //Obtention des titres pour la creation des colonnes de la tables
            List <string> titres = new List <string>();

            foreach (DataColumn t in dt.Columns)
            {
                if (t.ColumnName != "style" && t.ColumnName != "graph")
                {
                    if (t.ColumnName == " ")
                    {
                        titres.Add("%");
                    }
                    else
                    {
                        titres.Add(t.ColumnName);
                    }
                }
            }

            //ecriture des titres
            SheetData sd = worksheetPart.Worksheet.GetFirstChild <SheetData>();
            Row       rr = XcelWin.creerTitres(dt, 1);

            sd.AppendChild(rr);

            //ecriture des données
            int index = 2;

            foreach (DataRow r in dt.Rows)
            {
                rr = XcelWin.creerLigne(r, index, 0, nbColonneConfig);
                sd.AppendChild(rr);
                index++;
            }

            XcelWin.AddTableDefinitionPart(worksheetPart, titres, dt.Rows.Count + 1, dt.Columns.Count - nbColonneConfig, indice);
            TableParts tableParts1 = new TableParts()
            {
                Count = (UInt32Value)1U
            };
            TablePart tablePart1 = new TablePart()
            {
                Id = "vId1"
            };

            tableParts1.Append(tablePart1);

            worksheetPart.Worksheet.Append(tableParts1);
        }
        public void ecrireMetaChartData(WorksheetPart worksheetPart, Dictionary <string, Object> d)
        {
            SheetData sd = worksheetPart.Worksheet.GetFirstChild <SheetData>();
            int       i  = 1;

            foreach (string key in d.Keys.Where(s => s.Contains("meta")))
            {
                //Enregistre la ligne de début du tableau de ce metachart
                ((MetaChartData)d[key]).indice = i;

                //Ligne d'axisData
                Row           rr  = new Row();
                int           k   = 1;
                MetaChartData tmp = (MetaChartData)d[key];
                foreach (string serie in tmp.series)
                {
                    Cell ceee = XcelWin.createTextCell(headerColumns[k], i, ((ChartData)d[serie]).nomModele, 0);
                    rr.Append(ceee);
                    k++;
                }
                sd.Append(rr);
                i++;

                //le nombre de ligne de data
                //Les formules de data et titre de series
                foreach (int data in ((ChartData)d[tmp.series.First()]).data)
                {
                    Row r = new Row();

                    string titre   = ((ChartData)d[tmp.series.First()]).colTitres;
                    string feuille = ((ChartData)d[tmp.series.First()]).titre;//nomModele

                    Cell cee = GenerateCell(headerColumns[0] + i, "'" + feuille + "'!$" + titre + "$" + data);
                    r.Append(cee);
                    //le nombre de serie
                    int j = 1;
                    foreach (string serie in tmp.series)
                    {
                        //string formule = "" + ((ChartData)d[serie]).nomModele + "!$" + ((ChartData)d[serie]).colValeurs + "$" + data;
                        string formule = "'" + ((ChartData)d[serie]).titre + "'!$" + ((ChartData)d[serie]).colValeurs + "$" + data;
                        Cell   ce      = GenerateCell(headerColumns[j] + i, formule);
                        r.Append(ce);
                        j++;
                    }
                    i++;
                    sd.Append(r);
                }
            }
        }
Exemple #8
0
        public void exec(System.Data.DataTable dt)
        {
            System.IO.File.Copy(template, copie, true);
            SpreadsheetDocument myWorkbook   = SpreadsheetDocument.Open(copie, true);
            WorkbookPart        workbookPart = myWorkbook.WorkbookPart;

            WorksheetPart wsPart = XcelWin.getWorksheetPartByName(myWorkbook, "Feuil1");

            //DocumentFormat.OpenXml.Spreadsheet.Columns columns = new Columns();
            //for(int i=0;i<size.Length;i++)
            //{
            //    DocumentFormat.OpenXml.Spreadsheet.Column c = new Column();
            //    c.CustomWidth = true;
            //    c.Min = (uint) i+1;
            //    c.Max = (uint) i+1;
            //    c.Width = size[i];

            //    columns.Append(c);
            //}

            //DocumentFormat.OpenXml.Spreadsheet.Columns cc = new Columns();
            //cc.Append(new DocumentFormat.OpenXml.Spreadsheet.Column() { Min = 1, Max = 3, CustomWidth = true, Width = 5 });
            ////wsPart.Worksheet.Append(cc);
            //Worksheet ws = wsPart.Worksheet;
            //ws.Append(cc);



            DrawingsPart drawingsPart1 = wsPart.AddNewPart <DrawingsPart>("rId1");

            XcelWin.GenerateDrawingsPart1Content(drawingsPart1);

            ChartPart chartPart1 = drawingsPart1.AddNewPart <ChartPart>("rId1");

            XcelWin.GenerateChartPart1Content(chartPart1);

            Drawing drawing1 = new Drawing()
            {
                Id = "rId1"
            };

            wsPart.Worksheet.Append(drawing1);



            workbookPart.Workbook.Save();
            myWorkbook.Close();
        }
        public Row creerTitres(DataTable dt, int indiceLigne)
        {
            int i = 0;
            Row r = new Row();

            r.RowIndex = (uint)indiceLigne;

            foreach (DataColumn DC in dt.Columns)
            {
                if (DC.ColumnName != "style")
                {
                    r.AppendChild(XcelWin.createTextCell(headerColumns[i], indiceLigne, DC.ColumnName, 0));
                    i++;
                }
            }
            return(r);
        }
Exemple #10
0
        //-----------------------------------------------------------------------------------
        //Tests sur les charts

        public void exec(string formuleVal, string formuleLegende)
        {
            string label = "Feuil1!D5:J5";
            string serie = "Feuil1!C12";
            string val   = "Feuil1!D12:J12";

            //euro	mmp	mut2m	cmav	sapem	quatrem	auxia

            System.IO.File.Copy(template, copie, true);
            SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(copie, true);

            ChartPart cc = XcelWin.cloneChart(XcelWin.getWorksheetPartByName(myWorkbook, "Feuil1"), "Tests", 0, 0, 10, 10);



            BarChart bc = cc.ChartSpace.Descendants <BarChart>().First();

            for (int i = 0; i < 6; i++)
            {
                BarChartSeries newSerie = (BarChartSeries)bc.Elements <BarChartSeries>().First().CloneNode(true);

                string form = val.Replace("12", (6 + i).ToString());

                newSerie.SeriesText.StringReference.Formula.Text = serie;
                //newSerie.Descendants<CategoryAxisData>().First().Remove();

                newSerie.Descendants <CategoryAxisData>().First().NumberReference.Formula.Text = label;
                newSerie.Descendants <Charts.Values>().First().NumberReference.Formula.Text    = form;


                newSerie.Index.Val = (uint)i;
                newSerie.Order.Val = (uint)i;

                bc.Append(newSerie);
            }

            bc.Elements <BarChartSeries>().First().Remove();

            myWorkbook.WorkbookPart.Workbook.Save();
            myWorkbook.Close();
        }
Exemple #11
0
        public void exec()
        {
            System.IO.File.Copy(template, copie, true);
            SpreadsheetDocument myWorkbookCopie  = SpreadsheetDocument.Open(copie, true);
            SpreadsheetDocument myWorkbookSource = SpreadsheetDocument.Open(source, true);

            ////Obtention du graph
            ////WorkbookPart workbookPart = myWorkbookSource.WorkbookPart;
            ////WorksheetPart worksheetPart = workbookPart.WorksheetParts.ElementAt<WorksheetPart>(2);
            //WorksheetPart worksheetPart = XcelWin.GetWorksheetPartByName(myWorkbookSource, "REPORTING");
            //DrawingsPart a = worksheetPart.DrawingsPart;
            //ChartPart b = a.ChartParts.ElementAt(0);


            ////Creation drawingpart et chartpart
            //WorkbookPart workbookPart2 = myWorkbookCopie.WorkbookPart;
            //WorksheetPart worksheetPart2 = workbookPart2.WorksheetParts.ElementAt<WorksheetPart>(0);
            //DrawingsPart dp = worksheetPart2.AddNewPart<DrawingsPart>();
            //ChartPart x = dp.AddNewPart<ChartPart>();

            //x.FeedData(b.GetStream());

            WorkbookPart  workbookPart2 = myWorkbookCopie.WorkbookPart;
            WorksheetPart worksheetPart = XcelWin.getWorksheetPartByName(myWorkbookCopie, "REPORTING");

            string[] labels = { "a", "b", "c" };
            double[] data   = { 2.2, 3.3, 5.5 };

            //Permet de mettre un chart avec des données
            PieChartSeries pcs = GeneratePieChartSeries(labels, data);
            Chart          x   = getChartByTitle(worksheetPart, "Ressource");
            PieChart       px  = x.Descendants <PieChart>().First();

            px.RemoveAllChildren <PieChartSeries>();
            px.Append(pcs);


            workbookPart2.Workbook.Save();
            myWorkbookCopie.Close();
        }
Exemple #12
0
        /*
         * public void execution(DataTable[] dt)
         * {
         *
         *  //Copie du template et ouverture du fichier
         *  System.IO.File.Copy(template, copie, true);
         *  myWorkbook = SpreadsheetDocument.Open(copie, true);
         *
         *
         *  //Access the main Workbook part, which contains all references.
         *  WorkbookPart workbookPart = myWorkbook.WorkbookPart;
         *
         *  //0 : feuille 1
         *  //4 : feuille 2
         *  //3 : feuille 3
         *
         *
         *  //WorksheetPart worksheetPart = workbookPart.WorksheetParts.ElementAt<WorksheetPart>(2);
         *  //SheetData sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();
         *  ////Ajout de la date sur la page de garde
         *  //Cell cell = XcelWin.CreateTextCell("A", 1, "IRCEM", 0);
         *  //Row r = new Row();
         *  //r.RowIndex = 1;
         *  //r.AppendChild(cell);
         *  //sheetData.AppendChild(r);
         *
         *
         *  WorksheetPart wp = workbookPart.WorksheetParts.ElementAt<WorksheetPart>(0);
         *  creerFeuille(wp, dt[0]);
         *
         *  wp = workbookPart.WorksheetParts.ElementAt<WorksheetPart>(5);
         *  creerFeuille(wp, dt[1]);
         *
         *  wp = workbookPart.WorksheetParts.ElementAt<WorksheetPart>(4);
         *  creerFeuille(wp, dt[2]);
         *
         *  wp = workbookPart.WorksheetParts.ElementAt<WorksheetPart>(3);
         *  creerFeuille(wp, dt[3]);
         *
         *  myWorkbook.WorkbookPart.Workbook.CalculationProperties.ForceFullCalculation = true;
         *  myWorkbook.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true;
         *
         *  //Sauvegarde du workbook et fermeture de l'objet fichier
         *  workbookPart.Workbook.Save();
         *  myWorkbook.Close();
         * }
         */

        public void execution2(DataSet ds)
        {
            //Copie du template et ouverture du fichier
            System.IO.File.Copy(template, copie, true);
            myWorkbook = SpreadsheetDocument.Open(copie, true);


            //Access the main Workbook part, which contains all references.
            WorkbookPart workbookPart = myWorkbook.WorkbookPart;


            WorksheetPart wp = XcelWin.getWorksheetPartByName(myWorkbook, "Feuil1");

            creerFeuille2(wp, ds);


            myWorkbook.WorkbookPart.Workbook.CalculationProperties.ForceFullCalculation  = true;
            myWorkbook.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true;

            //Sauvegarde du workbook et fermeture de l'objet fichier
            workbookPart.Workbook.Save();
            myWorkbook.Close();
        }
        //Remplissage de la feuille en mode Report (mode normal)
        public void creerFeuille(WorksheetPart worksheetPart, DataTable dt)
        {
            //Atention  ne pas oublier l'obtention des bornes
            obtentionBornesColonnes(dt);

            SheetData sd = worksheetPart.Worksheet.GetFirstChild <SheetData>();

            Row r = XcelWin.creerTitres(dt, 1);

            sd.AppendChild(r);

            int index = 2;

            r = new Row();
            foreach (DataRow item in dt.Rows)
            {
                uint[] a = new uint[6];
                if (indiceSyle != -1 && stylePath != null)
                {
                    int tmp = Convert.ToInt32(item.ItemArray[indiceSyle]);
                    a = lineStyles[tmp];
                }

                if (indiceRubrique == 0 && indiceLibelle == 0)
                {
                    r = XcelWin.creerLigne(item, index, a[0], nbColonneConfig);
                }
                else
                {
                    r = creerLigne(item, index, a, nbColonneConfig);
                }

                sd.AppendChild(r);
                index++;
            }
        }
        public static Row creerTitres(DataTable dt, int indiceLigne)
        {
            int i = 0;
            Row r = new Row();

            r.RowIndex = (uint)indiceLigne;

            foreach (DataColumn DC in dt.Columns)
            {
                if (DC.ColumnName != "style" && DC.ColumnName != "graph")
                {
                    if (DC.ColumnName == " ")
                    {
                        r.AppendChild(XcelWin.createTextCell(Ultimate.headerColumns[i], indiceLigne, "%", 0));
                    }
                    else
                    {
                        r.AppendChild(XcelWin.createTextCell(Ultimate.headerColumns[i], indiceLigne, DC.ColumnName, 0));
                    }
                    i++;
                }
            }
            return(r);
        }
        public void execution(DataSet dt, string date, string[] sheetNames, bool monoFeuille = false)
        {
            if (monoFeuille)
            {
                //Copie du template et ouverture du fichier
                System.IO.File.Copy(template, copie, true);
                SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(copie, true);

                //Access the main Workbook part, which contains all references.
                WorkbookPart  workbookPart = myWorkbook.WorkbookPart;
                WorksheetPart wp           = XcelWin.getWorksheetPartByName(myWorkbook, "Feuil1");
                creerFeuille2(wp, dt);

                myWorkbook.WorkbookPart.Workbook.CalculationProperties.ForceFullCalculation  = true;
                myWorkbook.WorkbookPart.Workbook.CalculationProperties.FullCalculationOnLoad = true;

                //Sauvegarde du workbook et fermeture de l'objet fichier
                workbookPart.Workbook.Save();
                myWorkbook.Close();
            }
            else
            {
                //Copie du template et ouverture du fichier
                System.IO.File.Copy(template, copie, true);
                SpreadsheetDocument myWorkbook = SpreadsheetDocument.Open(copie, true);

                //Access the main Workbook part, which contains all references.
                WorkbookPart workbookPart = myWorkbook.WorkbookPart;

                if (stylePath != null)
                {//Importation des styles contenus dans le fichier de style
                    //Copie du StyleSheet existant pour ne pas perdre les elements du template
                    var        wsp = workbookPart.WorkbookStylesPart;
                    Stylesheet ss  = wsp.Stylesheet;
                    // Comme on a fait une copie, on doit supprimer le WorkbookStylePart oiginal
                    workbookPart.DeletePart(wsp);
                    // Et on y ajoute le notre
                    WorkbookStylesPart wbsp = workbookPart.AddNewPart <WorkbookStylesPart>();
                    //Importation des styles contenus dans le fichier de style
                    Interface itf = new Interface();
                    itf.lectureFichier(ss, stylePath);
                    wbsp.Stylesheet = ss;
                    wbsp.Stylesheet.Save();
                    lineStyles = itf.lineStyles;
                }

                //WorksheetPart que l'on va copier
                WorksheetPart worksheetPart = XcelWin.getWorksheetPartByName(myWorkbook, "Feuil1");

                //Obtention des conf de graph : modeles, titres, colonnes ...
                Dictionary <string, Object> d = new Dictionary <string, Object>();
                if (graphPath != null)
                {
                    d = Interface.lectureConfGraph(graphPath);
                }
                WorksheetPart graphs = XcelWin.getWorksheetPartByName(myWorkbook, "Graphs");

                //Dimension du plus grand des graphs (pour les placer sans superposition par la suite)
                //maxJ pour savoir ou placer les metagraphs par la suite
                int maxLi = -1, maxCol = -1;
                int maxJ = 0;
                try
                { XcelWin.maxDimChart(graphs, out maxLi, out maxCol); }
                catch (NullReferenceException)
                { Console.WriteLine("Aucun graph présent dans la feuille 'graph' \nIgnore toutes les operations relatives aux graphs"); }


                //Creation de chacunes des feuilles
                for (int i = 0; i < dt.Tables.Count; i++)
                {
                    //obtention du nom pour la feuille, si absent : Sheet 1, 2, 3...
                    string nom = "";
                    try { nom = sheetNames[i]; }
                    catch (Exception) { nom = "Sheet" + (i + 1); }

                    WorksheetPart wp = CopySheet(workbookPart, worksheetPart, nom);

                    int tab = -1;
                    foreach (string clef in d.Keys.Where(s => s.Contains("tableau")))
                    {
                        if (((TableauData)d[clef]).indice == i)
                        {
                            tab = i;
                        }
                    }
                    if (tab != -1)
                    {
                        creerTableau(wp, dt.Tables[i], i + 1);
                    }
                    else
                    {
                        creerFeuille(wp, dt.Tables[i]);
                    }


                    //Obtention des lignes de données des graphs
                    d = Interface.razConfGraph(d);
                    if (indiceGraph != -1)
                    {
                        obtInfosGraphs(dt.Tables[i], d, nom);
                    }
                    int j = 0;

                    //Si on a trouvé des graphs lors de l'obtention de leurs tailles
                    if (maxLi != -1)
                    {
                        //Creation des graphs qui ont les clefs de type graph
                        foreach (string clef in d.Keys.Where(s => s.Contains("graph") && ((ChartData)d[s]).data.Count != 0))
                        {
                            ChartData tmp = (ChartData)d[clef];
                            ChartPart y   = XcelWin.cloneChart(graphs, tmp.nomModele, i, j, maxLi, maxCol);
                            if (tmp.colValeurs == "last")
                            {
                                XcelWin.fixChartData(y, nom, tmp.data, headerColumns[dt.Tables[i].Columns.Count - nbColonneConfig - 1], getHeaderCol(tmp.colTitres, dt.Tables[i]));
                            }
                            else
                            {
                                try { XcelWin.fixChartData(y, nom, tmp.data, getHeaderCol(tmp.colValeurs, dt.Tables[i]), getHeaderCol(tmp.colTitres, dt.Tables[i])); }
                                catch (Exception) { Console.WriteLine("Echec de mise à jour des données du graph, verifier le fichier de configuration " + clef); }
                            }
                            XcelWin.fixChartTitle(y, tmp.titre + " " + nom);
                            j++;
                        }
                        if (j > maxJ)
                        {
                            maxJ = j;
                        }
                    }
                }
                //Si on a trouvé des graphs lors de l'obtention de leurs tailles
                if (maxLi != -1)
                {
                    //Creation des metagraphs
                    WorksheetPart wp2 = XcelWin.addWorksheetPart(myWorkbook, "data");
                    ecrireMetaChartData(wp2, d);
                    int k = 0;
                    foreach (string key in d.Keys.Where(s => s.Contains("meta")))
                    {
                        MetaChartData tmp = (MetaChartData)d[key];
                        try
                        {
                            ChartPart     cp = XcelWin.cloneChart(graphs, tmp.nomModele, k, maxJ, maxLi, maxCol);
                            List <string> formules;
                            if (tmp.transpose)
                            {
                                formules = creaFormuleTranspose(((ChartData)d[tmp.series.First()]).data.Count, tmp.series.Count, tmp.indice);
                            }
                            else
                            {
                                formules = creaFormule(((ChartData)d[tmp.series.First()]).data.Count, tmp.series.Count, tmp.indice);
                            }
                            XcelWin.majMetaChart(cp, formules);
                            XcelWin.fixChartTitle(cp, tmp.titre);
                            k++;
                        }
                        catch (Exception) { Console.WriteLine("Impossible de copier un graph (verifiez que le graph est présent dans le template avec le bon titre) : " + tmp.nomModele); }
                    }

                    //Cache la feuille de donnée des metagraph
                    Sheet sData = XcelWin.getSheetByName(workbookPart, "data");
                    sData.State       = new SheetStateValues();
                    sData.State.Value = SheetStateValues.Hidden;

                    //suppression des modèles de graphs
                    List <string> listeModele = new List <string>();
                    foreach (string key in d.Keys.Where(s => s.Contains("graph") || s.Contains("meta")))
                    {
                        string nomModele = "";
                        try { nomModele = ((ChartData)d[key]).nomModele; }
                        catch (Exception) { nomModele = ((MetaChartData)d[key]).nomModele; }
                        if (!listeModele.Contains(nomModele))
                        {
                            listeModele.Add(nomModele);
                            try { XcelWin.supprChart(graphs, nomModele); }
                            catch (Exception) { Console.WriteLine("Impossible de supprimer le modèle car introuvable : " + nomModele); }
                        }
                    }
                }

                try
                {//Ajout de la date sur la page de garde
                    Cell cell = XcelWin.createTextCell("H", 27, date, 0);
                    Row  r    = new Row();
                    r.RowIndex = 27;
                    r.AppendChild(cell);
                    worksheetPart = XcelWin.getWorksheetPartByName(myWorkbook, "REPORTING");;
                    SheetData sheetData = worksheetPart.Worksheet.GetFirstChild <SheetData>();
                    sheetData.AppendChild(r);
                }
                catch (Exception)
                {
                    Console.WriteLine("Erreur lors de l'ajout de la date sur la page de garde 'REPORTING'");
                }

                //Suppression du worksheetPart qui a servis de modele
                workbookPart.DeletePart(XcelWin.getWorksheetPartByName(myWorkbook, "Feuil1"));
                XcelWin.getSheetByName(workbookPart, "Feuil1").Remove();

                //Sauvegarde du workbook et fermeture de l'objet fichier
                workbookPart.Workbook.Save();
                myWorkbook.Close();
            }
        }
        //Creation d'une ligne en mode Report (normal)
        public Row creerLigne(DataRow dr, int index, uint[] style, int nbColonneConfig)
        {
            Row  r = new Row();
            Cell c = new Cell();
            int  i = 0;

            //Skip pour ne pas écrire la colonne de style ni la colonne graph
            foreach (var att in dr.ItemArray.Skip(nbColonneConfig))
            {
                c = new Cell();
                //Partie gauche
                if (i < indiceRubrique - nbColonneConfig)
                {
                    try { c = XcelWin.createCellFloat(headerColumns[i], index, Convert.ToSingle(att), style[0]); }
                    catch (Exception) { string tmp; if (att == DBNull.Value)
                                        {
                                            tmp = "";
                                        }
                                        else
                                        {
                                            tmp = (string)att;
                                        } c = XcelWin.createTextCell(headerColumns[i], index, tmp, style[0]); }
                }
                //debut partie texte
                else if (i == indiceRubrique - nbColonneConfig)
                {
                    c = XcelWin.createTextCell(headerColumns[i], index, (string)att, style[1]);
                }
                //partie texte
                else if (indiceRubrique - nbColonneConfig < i && i < indiceLibelle - nbColonneConfig)
                {
                    c = XcelWin.createTextCell(headerColumns[i], index, (string)att, style[2]);
                }
                //Fin partie texte
                else if (i == indiceLibelle - nbColonneConfig)
                {
                    c = XcelWin.createTextCell(headerColumns[i], index, (string)att, style[3]);
                }
                //Derniere colonne
                else if (i == dr.ItemArray.Count() - nbColonneConfig - 1)
                {
                    double resultat;
                    if (att == DBNull.Value)
                    {
                        resultat = 0.0;
                    }
                    else
                    {
                        resultat = (double)att;
                    }
                    c = XcelWin.createCellDouble(headerColumns[i], index, resultat, style[5]);
                }
                else
                {
                    double resultat;
                    if (att == DBNull.Value)
                    {
                        resultat = 0.0;
                    }
                    else
                    {
                        resultat = Convert.ToDouble(att);
                    }
                    c = XcelWin.createCellDouble(headerColumns[i], index, resultat, style[4]);
                }
                r.AppendChild(c);
                i++;
            }

            return(r);
        }
 public static uint toStyle(Stylesheet ss, string style)
 {
     string[] arg = style.Split(';');
     return(XcelWin.creerStyle(ss, arg[0], Convert.ToInt32(arg[1]), Convert.ToBoolean(arg[2]), rgbToHexa(arg[3]), rgbToHexa(arg[4]), arg[5], arg[6], arg[7], arg[8], Convert.ToUInt32(arg[9])));
 }