StringBuilder sb = new StringBuilder()
sb
AppendLine(
<table><tr><th>序號</th><th>批單號</th><th>保單號</th><th>被保險人</th><th>保全項目</th><th>退費金額</th><th>保全操作日期</th><th>經辦人</th></tr>
)
int i =
;
string str =
abc
;
string str
=
wanglei
;
string str
=
aaa
;
string time
= DateTime
Now
ToString()
sb
AppendLine(
<tr><td>
</td><td style=\
vnd
ms
excel
numberformat:@\
>
+
+
</td><td style=\
vnd
ms
excel
numberformat:@\
>
+ str +
</td><td>
+ str
+
</td><td>
+ str
+
</td><td>
+
</td><td>
+ time
+
</td><td>
+ str +
</td></tr>
)
//foreach (BillChange change in list)
//{
// sb
AppendLine(
<tr><td>
+ (i++)
ToString() +
</td><td style=\
vnd
ms
excel
numberformat:@\
>
+ change
ChangeBillCode +
</td><td style=\
vnd
ms
excel
numberformat:@\
>
+ change
BillCode +
</td><td>
+ change
BillHolder +
</td><td>
+ GetChangeTypeString(change
ChangeType) +
</td><td>
+ (change
ReturnFee >
? change
ReturnFee
ToString() :
) +
</td><td>
+ change
CreateDatetime
ToString(
yyyy
MM
dd
) +
</td><td>
+ change
CreatorName +
</td></tr>
)
//}
sb
Insert(
<html><head><meta content=
text/html; charset=utf
http
equiv=
content
type
/></head><body><table border=
>
)
sb
AppendLine(
</table></body></html>
)
Response
Clear()
Response
Buffer = true;
Response
Charset =
UTF
;
Response
AppendHeader(
Content
Disposition
attachment;filename=\
+ Server
UrlEncode(
保單變更信息
xls
) +
\
)
Response
ContentEncoding = Encoding
UTF
;
Response
ContentType =
application/ms
excel
;
Response
Write(sb
ToString())
Response
End()
From:http://tw.wingwit.com/Article/program/net/201311/13218.html