//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); }
//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); }