Bonjour,

J'ai précédemment créé en ASP.NET un bouton qui permettait d'exporter un tableau ASP dans un fichier xls et cela fonctionnait bien.

Maintenant j'aimerai le faire de la même manière dans un winform (c'est à dire sans utiliser l'automation que j'abhorre).

Voici mon précédent code:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
 
protected void EExcel_Click(object sender, System.EventArgs e)
{
// Set the content type to Excel.
Response.ContentType = "application/vnd.ms-excel";
// Remove the charset from the Content-Type header.
Response.Charset = "";
// Turn off the view state.
this.EnableViewState = false;
remplirtableauventilation();
 
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
 
 // Get the HTML for the control.
tblventilation.RenderControl(hw);
 
Response.Write("<?xml version=1.0 encoding=utf-8?><html><body>");
// Write the HTML back to the browser.
Response.Write(tw.ToString);
Response.Write("</body></html>");
// End the response.
Response.End();
}
remplirtableauventilation() étant la méthode qui remplissait mon tableau et tblventilation le nom du tableau.

Comment puis je changer le code?

Quel tableau puis je remplir facilement dans un winform et utiliser pour un export dans un tableau Excel?

Merci d'avance


MadMarc52