Back to "Cosetta stupida...classe che emette una tabella compatibile con Excel da un DataSet"

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

Cosetta stupida...classe che emette una tabella compatibile con Excel da un DataSet

Friday, 26 March 2004

Molto semplice e basato sulla uno di cui ho fatto il blog in precedenza (beh non in base al codice ma in base alla stessa idea). In ogni caso, collegare questo fino a un pulsante di collegamento, passare in un set di dati e fornirà un file compatibile Excel scaricabile ...

classe pubblica GetExcel

{

vuoto statico pubblico Convert(DataSet ds, int dataTableId, HttpResponse response, string fileName)

{

DataGrid dg = nuova DataGrid();

dg.DataSource = ds.Tables[dataTableId];

dg.DataBind();

response.Buffer = true;

response.ContentType="application/vnd.ms-excel";

AddHeader("Content-Disposition," "attachment;filename=" + fileName) ;

usando(StringWriter sw = new StringWriter())

{

usando(HtmlTextWriter = nuovo HtmlTextWriter(sw)))

{

dg.RenderControl(scrittore);

risposta.Scrivi(sw.ToString());

}

}

risposta.Fine();

}

vuoto statico pubblico Convert(DataSet ds, int dataTableId, HttpResponse response)

{

Convert(ds,dataTableId,response,"report.xls");

}

vuoto statico pubblico Convert(DataSet ds, risposta HttpResponse)

{

Convert(ds,0,response);

}

}

logo

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