Exception Details: System.Data.OleDb.OleDbException: 'YSDTemplate$' 不是一个有效名称。请确认它不包含无效的字符或标点,且名称不太长。Source Error:
Line 79: oledbconn.Open();
Line 80: OleDbCommand oledbcom=new OleDbCommand("select * from [YSDTemplate$]",oledbconn);
Line 81: OleDbDataReader oledbdr=oledbcom.ExecuteReader(CommandBehavior.CloseConnection);
Line 82:
Line 83: while(oledbdr.Read())
坐等帮助,谢谢各位
Line 79: oledbconn.Open();
Line 80: OleDbCommand oledbcom=new OleDbCommand("select * from [YSDTemplate$]",oledbconn);
Line 81: OleDbDataReader oledbdr=oledbcom.ExecuteReader(CommandBehavior.CloseConnection);
Line 82:
Line 83: while(oledbdr.Read())
坐等帮助,谢谢各位
解决方案 »
- 获得实体类的描述
- LINQ to Entities 不识别方法
- 请问ASP.NET里有没有像JAVA里的那种spring什么的框架,这种东西是叫MVC吗?
- 如何在Gridview里用link
- |zyciis| 第四贴:正则表达式散分贴 今天写了个正则总是不过,原来是自己粗心把 * 当 + 用 前10位每人10分 谢谢
- 怎样在Gridview中在点“编辑”时只能修改当前行,而让其他行不是编辑状态?参与者有分!
- 关于G#语言,各位有何看法???
- 请教高手:DataGrid控件怎么在属性生成器指定数据源?
- 极度郁闷,所有的asp页面突然之间都不好用了,请各位多多指点,太着急呀,不知究竟是怎么回来呀?
- 有没有做过bs里面的短信发送功能的。。
- panel简单问题,正解后即解贴!
- window.open()子窗口返回父窗口参数的问题!!急!急急!
OleDbCommand oledbcom=new OleDbCommand("select * from [Sheet1$]",oledbconn);
using System;
using System.Data;
using System.Data.OleDb;namespace Common
{
/// <summary>
/// Summary description for Excel.
/// </summary>
public class Excel
{
private const string STRING_CONECTTIONSTRING = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=\"Excel 8.0;HDR=Yes;IMEX=1;\"";
public Excel()
{
//
// TODO: Add constructor logic here
//
}
//excelFilePath Excel文件地址
public static DataTable GetDataTable(string excelFilePath)
{
try
{
DataSet ds = new DataSet();
string connstring = string.Format(STRING_CONECTTIONSTRING,excelFilePath);
string sql="select * from [Sheet1$]";
using(OleDbConnection cnn = new OleDbConnection(connstring))
{
cnn.Open();
OleDbDataAdapter dataAdapter = new OleDbDataAdapter(sql,cnn);
dataAdapter.Fill(ds);
cnn.Close();
return ds.Tables[0];
}
}
finally
{
}
}
}
}
NickLee.Common.Excel就可以直接导入导出www.cnblogs.com/mail-ricklee上有下载地址。