實現代碼如下:
1 /// <summary>
2 /// 設置Word模板,word表格樣式在此設置
3 /// </summary>
4 /// <param name="dsTr"></param>
5 /// <returns></returns>
6 protected string SetWordTemplate(string dsTr)
7 {
8 StringBuilder html = new StringBuilder();
9
10 html.Append("<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>");
11 html.Append("<html xmlns=http://www.w3.org/1999/xhtml>");
12 html.Append("<html><head><title>測試word</title></head>");
13 html.Append("<body>");
14 //html.Append("<table cellpadding=0 cellspacing=0 border=1>");
15 html.Append(dsTr);
16 //html.Append("</table>");
17 html.Append("</body>");
18 html.Append("</html>");
19
20 return html.ToString();
21 }
22
23 /// <summary>
24 /// 保存Word
25 /// </summary>
26 /// <param name="savePath"></param>
27 /// <param name="data"></param>
28