示例#1
0
        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);
        }
示例#2
0
        //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);
        }