Back to "Tyhmä pikku juttu...luokka, joka tuottaa Excel-yhteensopivan taulukon DataSetistä"

This is a viewer only at the moment see the article on how this works.

To update the preview hit Ctrl-Alt-R (or ⌘-Alt-R on Mac) or Enter to refresh. The Save icon lets you save the markdown file to disk

This is a preview from the server running through my markdig pipeline

ASP.NET C# Imported mostlylucidcouk

Tyhmä pikku juttu...luokka, joka tuottaa Excel-yhteensopivan taulukon DataSetistä

Friday, 26 March 2004

Hyvin yksinkertainen ja perustuu eräs, josta bloggasin aiemmin (no ei perustu koodiin, vaan samaan ideaan). Kytke tämä kuitenkin linkkipainikkeeseen, syötä dataan ja se tarjoaa ladattavan Excel-yhteensopivan tiedoston...

julkinen luokka Get Excel

{

Julkinen staattinen tyhjiö Convert(DataSet ds, int dataTableId, HttpResponse vastaus, merkkijono tiedostoName)

{

DataGrid dg = uusi DataGrid ();

dg.Tietolähde = ds.Taulukot[tiedottaulukostaId];

dg.DataBind();

vastaus.Buffer = totta;

vastaus.ContentType="sovellus/vnd.ms-excel";

vastaus.Lisää otsikko ("Sisällysluettelo"), "liittäminen; tiedostonimi=" + tiedostonimi) ;

using(StringWriter sw = uusi StringWriter ())

{

using(HtmlTextWriter writer writer = uusi HtmlTextWriter (sw))

{

dg.RenderControl (kirjailija)

response.Write(sw.ToString());

}

}

vastaus.End();

}

Julkinen staattinen tyhjiö Convert(DataSet ds, int dataTaulukkoId, HttpResponse reaction)

{

Muunna (ds,datataulukkoId, vastaus"report.xls");

}

Julkinen staattinen tyhjiö Convert(DataSet ds, HttpResponse reaction)

{

Muuntaminen (ds,0, vastaus);

}

}

logo

© 2026 Scott Galloway — Unlicense — All content and source code on this site is free to use, copy, modify, and sell.