C中数据导出到Excel表格(17)
发布时间:2021-06-07
发布时间:2021-06-07
DataGridView 数据导出到Excel
8. //throw new Exception("文件删除失败");
9. }
10. else
11. {
12. fi.Create();
13. }
14.
15. string mailto:sqlcon=@%22Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
+ filePath + ";Extended ProPerties=Excel 8.0;";
16. OleDbConnection olecon = new OleDbConnection(sqlcon);
17. OleDbCommand olecmd = new OleDbCommand();
18. olecmd.Connection = olecon;
19. mandType = CommandType.Text;
20.
21. try
22. {
23. olecon.Open();
24.
25. XmlNode nodec=node.SelectSingleNode("./Method/ShowField");
26. int ii = 0;
27. sqlstr = "CREATE TABLE sheet1(";
28. foreach(XmlNode xnode in nodec.ChildNodes )
29. {
30. if(ii == nodec.ChildNodes.Count - 1)
31. {
32. if(xnode.Attributes["type"].Value.ToLower() ==
"int"||xnode.Attributes["type"].Value.ToLower() == "decimal")
33. {
34. sqlstr=sqlstr + xnode.Attributes["displayname"].Value + " number)";
35. }
36. else
37. {
38. sqlstr=sqlstr + xnode.Attributes["displayname"].Value + " text)";
39. }
40. // sqlstr=sqlstr + xnode.Attributes["displayname"].Value + " text)";
上一篇:红楼梦人物描写风格浅析
下一篇:美国联邦制的发展。