解析SQLServer獲取Excel中所有Sheet的方法建站知識(shí)
導(dǎo)讀:1建站知識(shí)本篇文章是對SQLServer獲取Excel中所有Sheet的方法進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下公司網(wǎng)站建設(shè)網(wǎng)站建設(shè)公司。
E盤根目錄新建一個(gè)Excel文件aa.xls后測試如下代碼
復(fù)制代碼 代碼如下:
use tempdb go if (網(wǎng)站建設(shè)多少錢object_id ('udf_getExcelTableNames' ) is not null ) drop function dbo .udf_getExcelTableNames go create function udf_getExcelTableNames (@filename varchar (1000 ))returns @t table (id int , name varchar (255 ))as begin declare @error int , seo網(wǎng)站優(yōu)化@obj int , @c int , @sheetname varchar (255 ) , @sheetstring varchar (255 ) exec @error = sp_oacreate 'Excel.Application' , @obj out exec @error = sp_oamethod @obj , 'Workbooks.Open' , @c out , @filename exec @error = sp_oagetproperty @obj , 'ActiveWorkbook.Sheets.Count' , @c out while (@c > 0 ) begin set @sheetstring =網(wǎng)站seo優(yōu)化 'ActiveWorkbook.Sheets(' + ltrim (@c )+ ').Name' exec @error = sp_oagetproperty @obj , @sheetstring , @sheetname out insert into @t select @c , @sheetname set @c = @c - 1 end exec @error = sp_oadestroy @obj return end go select * from dbo .udf_getExcelTableNames ('e:/aa.xls' )/*--測試結(jié)果 3 Sheet3 2 Sheet2 1 Sheet1 */
相關(guān)公司網(wǎng)站建設(shè)網(wǎng)站建設(shè)公司。聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-23 ,文章解析SQLServer獲取Excel中所有Sheet的方法建站知識(shí)主要講述標(biāo)簽,標(biāo)題,SQL網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請保留鏈接: http://www.bifwcx.com/article/web_5460.html
為你推薦與解析SQLServer獲取Excel中所有Sheet的方法建站知識(shí)相關(guān)的文章
-
通王TWCMS 2.0.3網(wǎng)站模板程序下載
(126)人喜歡 2024-01-15 -
Windows官方原版在哪里下載
(175)人喜歡 2024-01-15 -
WordPress網(wǎng)站模板發(fā)帖標(biāo)題顏色設(shè)置
(131)人喜歡 2024-01-07 -
修改discuz論壇帖子標(biāo)題80字符的長度限制
(249)人喜歡 2024-01-07 -
wordpress程序調(diào)用不帶超鏈接的Tag標(biāo)簽
(234)人喜歡 2024-01-05 -
網(wǎng)站在不同時(shí)期需調(diào)整內(nèi)容更新的方向
(112)人喜歡 2023-08-12