操作后关闭EXCEL和释放资源GC.Collect().
解决方案 »
- 求助关于WINFORM代理的问题.
- 两个简单的正式表达式求教
- FirstDisplayedScrollingRowIndex的设置无效
- 在Access中,以字符串格式保存的日期如何正确排序?
- vs2005中 datagrid表头固定问题
- 100分求解:求高效的让关键字变色的方法
- 求一个程序 C#操作数据库 然后查询并显示 非常感谢
- c#能不能防止其他软件点击关闭按钮?
- Microsoft Visual Studio 2010 显示的「Expr」怎样设置成Microsoft Visual Studio 2008的样子
- 关于判断控件的类型,谢谢
- 关于sql server 2005 服务器名称的更改
- 水晶报表的参数传递问题?
下面插入数据的话找不到相应的字段
insert into Sheet1$
MyConn.ConnectionString = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" + Server.MapPath("/Excel.xls");
OdbcCommand MyComm = new OdbcCommand();
MyComm.Connection = MyConn;
MyComm.CommandText = "SELECT * FROM [Sheet1$]";
OdbcDataAdapter MyODA = new OdbcDataAdapter(MyComm);
DataTable MyTable = new DataTable();
MyODA.Fill(MyTable);
MyConn.Close();
要先创建文件,backup.xls文件,否则strConnExcel就报错说没有文件,电脑不会自动寻找创建的
2WinFomr程序占据数据,不关闭,就不能释放资源,数据库就无法写入excel
xmlns:x="urn:schemas-microsoft-com:office:excel"
xmlns="http://www.w3.org/TR/REC-html40"><head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 11">
<link rel=File-List href="TaskList_files/filelist.xml">
<link rel=Edit-Time-Data href="TaskList_files/editdata.mso">
<link rel=OLE-Object-Data href="TaskList_files/oledata.mso">
<!--[if gte mso 9]><xml>
<o:DocumentProperties>
<o:Author>cx15</o:Author>
<o:LastAuthor>cx15</o:LastAuthor>
<o:Created>2008-06-20T02:32:29Z</o:Created>
<o:LastSaved>2008-11-25T05:30:19Z</o:LastSaved>
<o:Company>Microsoft Corporation</o:Company>
<o:Version>11.9999</o:Version>
</o:DocumentProperties>
</xml><![endif]-->
<style>
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
@page
{margin:1.0in .75in 1.0in .75in;
mso-header-margin:.5in;
mso-footer-margin:.5in;}
tr
{mso-height-source:auto;
mso-ruby-visibility:none;}
col
{mso-width-source:auto;
mso-ruby-visibility:none;}
br
{mso-data-placement:same-cell;}
.style0
{mso-number-format:General;
text-align:general;
vertical-align:middle;
white-space:nowrap;
mso-rotate:0;
mso-background-source:auto;
mso-pattern:auto;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
border:none;
mso-protection:locked visible;
mso-style-name:Normal;
mso-style-id:0;}
td
{mso-style-parent:style0;
padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:windowtext;
font-size:12.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:none;
mso-background-source:auto;
mso-pattern:auto;
mso-protection:locked visible;
white-space:nowrap;
mso-rotate:0;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;
display:none;}
-->
</style>
<!--[if gte mso 9]><xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name>Sheet1</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:Selected/>
<x:Panes>
<x:Pane>
<x:Number>3</x:Number>
<x:ActiveRow>4</x:ActiveRow>
<x:ActiveCol>1</x:ActiveCol>
</x:Pane>
</x:Panes>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>Sheet2</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
<x:ExcelWorksheet>
<x:Name>Sheet3</x:Name>
<x:WorksheetOptions>
<x:DefaultRowHeight>285</x:DefaultRowHeight>
<x:ProtectContents>False</x:ProtectContents>
<x:ProtectObjects>False</x:ProtectObjects>
<x:ProtectScenarios>False</x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
<x:WindowHeight>11820</x:WindowHeight>
<x:WindowWidth>14955</x:WindowWidth>
<x:WindowTopX>480</x:WindowTopX>
<x:WindowTopY>15</x:WindowTopY>
<x:ProtectStructure>False</x:ProtectStructure>
<x:ProtectWindows>False</x:ProtectWindows>
</x:ExcelWorkbook>
</xml><![endif]-->
</head><body link=blue vlink=purple><table x:str border=0 cellpadding=0 cellspacing=0 width=120 style='border-collapse:
collapse;table-layout:fixed;width:90pt'>
<col width=120 style='mso-width-source:userset;mso-width-alt:3840;width:90pt'>
<tr height=19 style='height:14.25pt'>
<td height=19 width=120 style='height:14.25pt;width:90pt'>Cellvalue here</td>
</tr>
<tr height=19 style='height:14.25pt'>
<td height=19 style='height:14.25pt'>Cellvalue here</td>
</tr>
<![if supportMisalignedColumns]>
<tr height=0 style='display:none'>
<td width=120 style='width:90pt'></td>
</tr>
<![endif]>
</table></body></html>