C excel讀取表名,這樣獲取的表名不會出錯

2021-08-03 10:47:46 字數 562 閱讀 5144

對獲取的表名進行了過濾處理,提取出有效的表名,放到string中,應用的時候需要加上$符號,比如

本來:「select * from [sheet1$]」

獲得表名後string excelnames 需要 如對第乙個表名:"select * from"+" ["+excelnames[0]+"$"+"]"(跟原來的形式相同)

private string getexcelsheetnames(string filename)  

string excelsheets = new string[dt.rows.count];

int i = 0;

// 新增工作表名稱到字串陣列

foreach (datarow row in dt.rows)

//i++; //放在這裡是錯誤的,

} return excelsheets;

} catch (exception ex)

finally

if (dt != null)

} }

jdbc 獲取表名

在協作開發過程,特別是跨公司合作開發中,表的設計方和使用方完全不同。有時你需要知道表的結構,由於種種原因,一時無法得知表設計資訊。現在jdbc的resultsetmetadata物件可以幫你獲取表的資訊。resultsetmetadata是resultset介面的成員,提供了獲取表字段的方法。常見的...

C Excel 刪除指定的工作表

using m cel microsoft.office.interop.excel using system.io 輸出用路徑 p str excelputout system.environment.currentdirectory 測試用excel.xlsx 如果已存在,則刪除 if file...

利用註解獲取greendao的表名

greendao entity註解類原始碼中 retention retentionpolicy.source 表示編譯時有效,執行時是沒有效果的所以無法使用greendao的註解來進行對映獲取表名等屬性 首先自己新建註解類後重新註解 retention retentionpolicy.runtim...