我试过WPS的表格可以
可以
要代码么
百度都有
【深圳】Milen(99696619) 14:13:12
可以
需要吗
我有
connection.GetOleDbSchemaTable
通用
@【深圳】Milen
获取sheet
这个的哦
可能我忘了
public string GetExcelConn(string filepath)
{
string strConn = "";
int key = getOfficeKey();
if (key == 1)
{
strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + filepath + ";Extended Properties=Excel 8.0;";
}
else if (key == 2)
{
strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + filepath + ";Extended Properties=Excel 12.0;";
}
else if (key == 3)
{
strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + filepath + ";Extended Properties=Excel 8.0;";
}
else
{
strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source= " + filepath + ";Extended Properties=Excel 12.0;";
}
return strConn;
}
public void GetExcelTableName(string filepath)
{
tableNames.Items.Clear();
string strConn = GetExcelConn(filepath);
DataSet ds = new DataSet();
string tableName=string.Empty;
using (System.Data.OleDb.OleDbConnection connection = new System.Data.OleDb.OleDbConnection(strConn))
{
connection.Open();
DataTable table = connection.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
foreach (DataRow item in table.Rows)
{
tableNames.Items.Add(item["Table_Name"].ToString());
}
}
}
DataTable dt= conn.GetOleDbSchemaTable(System.Data.OleDb.OleDbSchemaGuid.Tables, null);
服务器只要安装这个就行了
connstr 就我刚才发的