//頁面
以下是引用片段
PrintClass myP = new PrintClass();
Response
在把DataGrid轉換為對應的HTML代碼時
導出到Excel
求客戶端在IE的安全設置上有一定要求
【實例代碼】
以下是引用片段
protected void btnMIME_Click(object sender
{
BindData();
Response
Response
//如果輸出為Word
//Response
//Response
StringBuilder sb=new StringBuilder();
System
System
sb
dgShow
sb
Response
Response
}
protected void btnCom_Click(object sender
{
ExportToExcel(BindData()
}
//從DataSet到出到Excel
#region從DataSet到出到Excel
///導出指定的Excel文件
public void ExportToExcel(DataSet ds
{
if (ds
doExport(ds
}
///執行導出
private void doExport(DataSet ds
{
excel
int rowIndex=
int colIndex=
excel
System
foreach(DataColumn col in table
{
colIndex++;
excel
}
foreach(DataRow row in table
{
rowIndex++;
colIndex=
foreach(DataColumn col in table
{
colIndex++;
excel
}
}
excel
excel
excel
excel=null;
GC
}
#endregion
[
From:http://tw.wingwit.com/Article/program/net/201311/14973.html