1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
protected void btnExporterCsv_Click(object sender, EventArgs e)
{
// recuperation des criteres
listeCriteres = recupererListeCriteres();
if (listeCriteres.Count == 0)
{
AfficherMessage("Liste de projets", "Au moins un critère soit être saisi", Severity.Warn);
return;
}
RechercherPrj(listeCriteres);
if (listeProjet != null && listeProjet.Count > 0)
{
// formattage du nom de fichier : Planification_YYYYMMDD.csv
DateTime aujourdhui = DateTime.Now;
string nomFichierCSV = string.Format("ExportTotalSRV_{0}.csv", aujourdhui.ToString("yyyyMMdd"));
//...
// création du memory stream msRetour
//...
// Supprime tout le contenu du flux de sortie envoyé au client
this.Response.Clear();
// Ajout d'un en-tête décrivant le flux envoyé au client
this.Response.AddHeader("content-disposition", "attachment; filename=" + nomFichierCSV);
this.Response.ContentType = "application/csv";
Encoding type_encode_prevu = srvExport.getConstEncodage();
this.Response.ContentEncoding = type_encode_prevu;
this.Response.BinaryWrite(type_encode_prevu.GetPreamble()); //
Response.BinaryWrite(msRetour.ToArray());
// test pour remettre le curseur en default
//if (!Page.ClientScript.IsStartupScriptRegistered("Curseur_Normal"))
//{
// Page.ClientScript.RegisterStartupScript
// (this.GetType(), "Curseur_Normal", "Curseur_Normal();", true);
//}
Page.ClientScript.RegisterStartupScript(this.GetType(), "Curseur_Normal", "document.body.style.cursor = 'default';",true);
// Fin de la réponse. Le code après n'est pas exécuté
this.Response.End();
}
else
{
AfficherMessage("Export Planification", "Aucun projet dans l'export demandé !", Severity.Error);
}
} |
Partager