我用以下的程序读取Excel文件的sheet name.
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("../Upload") + @"\" + userName + @".xls;Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""";
objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null)
{
return null;
} String[] excelSheets = new String[dt.Rows.Count];
int i = 0; // Add the sheet name to the string array.
foreach (DataRow row in dt.Rows)
{
string tableName = row["TABLE_NAME"].ToString();
string[] t = tableName.Split('$');
if (t[0].Contains("'"))
{ t[0] = t[0].Substring(1);
}
excelSheets[i] = t[0];
i++; }读取后把B2.2.1变成了B2#2#1了,请问解决呢?
string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" + Server.MapPath("../Upload") + @"\" + userName + @".xls;Extended Properties=""Excel 8.0;HDR=YES;IMEX=1;""";
objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null); if (dt == null)
{
return null;
} String[] excelSheets = new String[dt.Rows.Count];
int i = 0; // Add the sheet name to the string array.
foreach (DataRow row in dt.Rows)
{
string tableName = row["TABLE_NAME"].ToString();
string[] t = tableName.Split('$');
if (t[0].Contains("'"))
{ t[0] = t[0].Substring(1);
}
excelSheets[i] = t[0];
i++; }读取后把B2.2.1变成了B2#2#1了,请问解决呢?
解决方案 »
- VS2010创建网站添加引用问题
- 初入ASP.net 学习了C#,求介绍怎么学习ASP,
- 如何查询其他电脑上的access数据库?
- 在ASP.NET中,如果不用CSS,如何控制页面的布局,让页面更好看,如果不用CSS,页面很难控制啊,请问一下,怎么办,谢谢
- 求解图片上传后要取得图片路径的一个问题
- button1触发button2事件
- 新手作品:写了个留言本,大家来看看哦,评者有分(但要说实话)
- 有在线播放音乐的控件码?
- 在IIS上把网站挂上报错
- 如何获得 DropDownList所选项的DataValueField的值
- 我想学。NET
- response.cookies.set与response.cookies.add有何区别?
--------------------------
http://blog.cngator.com
————————————————
加在哪?可是excel的sheet名都不能填方括号.能具体吗?