解决方案 »
- C# Asp.net2.0 中怎么获得可用语言列表?????标题要长!~!!!!
- 时间为空时,字符转换报错! 怎么回事?
- 怎样把DataGridView中做的数据改变会反映到它所绑定的DataTable里
- C#做登陆器,为能实现,求帮助...
- 怎么实现用c# API 自动关闭当前窗口??
- 在C# winform中如何刷新窗体?
- 用c#复制一个Access数据库,操作设计到哪几个类?
- web下的程序设计有没有好的日期控件呀?C#本身提供的calender不是我需要的!谢谢...
- winform 这种效果怎么弄啊 在线等
- EditPlus的C#语法加亮文件
- 创建AddingMachine类,定义无参数方法Add和Subtract,分别实现两整型数的加、减
- C# .NET高手请进!!!
/// 删除
/// </summary>
/// <param name="strFileName"></param>
/// <returns></returns>
private void DropExcel(string strFileName)
{
string strConnection = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = "
+ strFileName + ";Extended Properties = Excel 8.0";
OleDbConnection oleConnection = new OleDbConnection(strConnection);
try
{
string strCommondText = " drop table [Sheet1$] ";
oleConnection.Open();
OleDbCommand oleAdper = new OleDbCommand(strCommondText,oleConnection);
oleAdper.ExecuteNonQuery();
}
catch(Exception ex)
{
throw new Exception("读取数据源文件时出错,错误消息:" + ex.Message);
}
finally
{
oleConnection.Close();
}
}这样可以么
new Microsoft.Office.Interop.Excel.ApplicationClass();
我就是不需要Office的组件,或者有没有其它的方式将数据保存在第一个work sheet1
/// 删除
/// </summary>
/// <param name="strFileName"> </param>
/// <returns> </returns>
private void DropExcel(string strFileName)
{
string strConnection = "Provider = Microsoft.Jet.OLEDB.4.0;" + "Data Source = "
+ strFileName + ";Extended Properties = Excel 8.0";
OleDbConnection oleConnection = new OleDbConnection(strConnection);
try
{
string strCommondText = " drop table [Sheet1$] ";
oleConnection.Open();
OleDbCommand oleAdper = new OleDbCommand(strCommondText,oleConnection);
oleAdper.ExecuteNonQuery();
}
catch(Exception ex)
{
throw new Exception("读取数据源文件时出错,错误消息:" + ex.Message);
}
finally
{
oleConnection.Close();
}
} 这样可以么----------------------------------------------
这种方式我也尝试过,只能删除数据,不能删除work sheet!