您的位置:程序门 -> .net技术 -> c#



读取 .xls 文件


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


读取 .xls 文件
发表于:2007-01-23 18:45:49 楼主
string   strcon   =   "   provider   =   microsoft.jet.oledb.4.0   ;   data   source   =   c:/sample.xls;extended   properties=excel   8.0; ";
oledbconnection   oconn   =   new   oledbconnection(strcon);
string   strcom   =   "   select   *   from   [1.   tsample] ";
oledbdataadapter   mycommand   =   new   oledbdataadapter(strcom,   oconn);
dataset   ds   =   new   dataset();
mycommand.fill(ds);

error:无效的括号名称   '1.   tsample '。

改为:
string   strcom   =   "   select   *   from   [1.   tsample$] ";   也不行

请问这是怎么回事啊?
谢谢!
发表于:2007-01-24 09:51:271楼 得分:0
string   strcom   =   "   select   *   from   [1.tsample$]   //去掉1.   后面的空格就行,有空格就不行
可是我要导入的文件.后面是有空格的,名称又不能修改
我该怎样处理啊
发表于:2007-01-24 09:53:472楼 得分:0
笨办法   先复制到临时文件夹   然后改名字   然后导入   导入完毕后删除
发表于:2007-01-24 10:17:023楼 得分:0
因为文件是受保护的,所有的东西都是只读的,名字不可修改,还有没有别的办法?


快速检索

最新资讯
热门点击