用access
dBase有人接盘了。
FOR i=1 TO FCOUNT() _zdmc=FIELDS(i) =MESSAGEBOX(_zdmc) IF TYPE(_zdmc)='C' CALCULATE MAX(LEN(ALLTRIM(&_zdmc))) TO ilen ALTER table hbsj alter &_zdmc. C(ilen) &&hbsj 为需要修改的dbf表名 ENDIF ENDFOR
cDefPath = ADDBS(JUSTPATH(SYS(16))) SET DEFAULT TO (cDefPath) xlsx = cDefPath + "hb2019sj.xlsx" oExcel = CREATEOBJECT('Excel.Application') oExcel.DisplayAlerts = 0 oExcel.WorkBooks.Open(xlsx) nRow = oExcel.Application.CountA(oExcel.ActiveSheet.Range("A:A")) - 1 nCol = oExcel.Application.CountA(oExcel.ActiveSheet.Range("1:1")) arrHead = oExcel.ActiveSheet.UsedRange.Cells(1,1).Resize(1,nCol).Value arrData = oExcel.ActiveSheet.UsedRange.Cells(2,1).Resize(nRow,nCol).Value oExcel.WorkBooks.Close oExcel.Quit cmd = "" FOR i=1 TO nCol f = arrHead[1,i] m = 10 FOR j=1 TO nRow IF VARTYPE(arrData[j,i]) != "N" n = LEN(arrData[j,i]) IF n > m m = n ENDIF ENDIF ENDFOR IF m < 255 cmd = cmd + ",_" + f + " V(" + TRANSFORM(m) + ")" ELSE cmd = cmd + ",_" + f + " M" ENDIF ENDFOR cmd = "CREATE CURSOR tt (" + SUBSTR(cmd,2) + ")" EXECSCRIPT(cmd) INSERT INTO tt FROM ARRAY arrData SELECT * FROM tt
[此贴子已经被作者于2021-7-2 20:58编辑过]