stdata 資料檔案,rngconfig 配置檔案
public function run(byref stdata as worksheet, byref rngconfig as range) as worksheet
'on error goto proc_err
dim r_config as integer, str_columnname as string
dim stnew as worksheet
'stdata.copy after:=stdata
stdata.activate
stdata.parent.sheets.add after:=stdata
set stnew = activesheet
stnew.name = rngconfig.worksheet.name
dim col as range, errmsg as string, c_new as integer
c_new = 0
for r_config = 2 to rngconfig.rows.count
str_columnname = rngconfig.cells(r_config, 1)
if str_columnname <> "" then
'msgbox str_columnname
call myfun.getcolumnbyname(stdata, 1, str_columnname, col, errmsg, false)
col.copy
c_new = c_new + 1
stnew.activate
stnew.cells(1, c_new).select
stnew.paste
end if
next r_config
exit function
end function
以下是函式方法:
rem 根據關鍵字,定位行
public function getrow(sheet as worksheet, tag as string, optional beginrow as long = 1) as long
dim r as long
with sheet.usedrange
for r = beginrow to .rows.count
if .cells(r, 1).value = tag then
getrow = r
exit function
end if
next
end with
getrow = 0
end function
rem 根據關鍵字,定位列
public function getcolumn(opsheet as worksheet, headerrow as long, tag as string) as integer
dim c as integer
dim msg as string
with opsheet
for c = 1 to .usedrange.columns.count
if .cells(headerrow, c) = tag then
getcolumn = c
exit function
end if
next
end with
getcolumn = 0
end function
rem 根據關鍵字,定位並返回列
public function getcolumnbyname(opsheet as worksheet, headerrow as long, tag as string, returncolumn as range, optional byref errmessage as string, optional showerrmsg as boolean = false) as boolean
getcolumnbyname = false
dim c as integer
c = getcolumn(opsheet, headerrow, tag)
if (c = 0) then
' showerrmsg = true
errmessage = "不能在底表[" & opsheet.name & "]中定位列[" & tag & "],請檢視該檔案的格式是否正確!"
if (showerrmsg) then
msgbox errmessage, vbinformation, "提示"
end if
exit function
else
set returncolumn = opsheet.columns(c)
end if
getcolumnbyname = true
end function
Python NLTK提取有用的chunk
文字的資訊很多,我們需要如何提取有用的資訊?比如一句話 json is a good boy 我們希望得到的資訊是json 和 a good boy 那麼首先我們需要對句子進行分詞和判斷單詞的屬性 可以用下面的 def ie preprocess document sentences nltk.se...
linux 提取指定的列
提取name.txt 檔案中的最後一列中以 分割的第二列 awk 符擷取命令 awk f t name.txt awk f res.txt其中 f 表示分割符,nf表示最後一列,nf 1 表示倒數第二列 2表示第二列 0表示全部,1表示第一列 把上一步的資料和name.txt檔案合併生成乙個新的檔案...
IDENTITY列的乙個有用操作
dbcc checkident 檢查指定表的當前標識值,如有必要,還對標識值進行更正。語法dbcc checkident table name 引數 table name 是要對其當前標識值進行檢查的表名。指定的表必須包含標識列。noreseed 指定不應更正當前標識值。reseed 指定應該更正當...