试了一下,另存为文本,这个文件格式还算规范,可以找到数据
程序代码:
cDefPath = ADDBS(JUSTPATH(SYS(16))) SET DEFAULT TO (cDefPath) ? "运行WORD......" oWord = CREATEOBJECT("Word.application") ? "打开文件......" oWord.Documents.Open(cDefPath+"2021年普通高中省级三好学生名单.docx") ? "另存文件......" oWord.ActiveDocument.SaveAs(cDefPath+"2021年普通高中省级三好学生名单.txt", 2) oWord.Documents.Close oWord.Quit ? "读取数据......" cTXT = FILETOSTR("2021年普通高中省级三好学生名单.txt") cTXT = RTRIM(cTXT, 0h0D,0h0A) USE shsmd ZAP n = ALINES(arr, cTXT, 5, "市"+0h0D) m = ALINES(ar, arr[1]) city = ar[m]+"市" FOR i=2 TO n m = ALINES(ar, arr[i], 5, 0h0D,0hA1A1) FOR j=7 TO m-2 STEP 3 INSERT INTO shsmd VALUES (ar[j],ar[j+1],city,ar[j+2]) ENDFOR city = ar[m]+"市" ENDFOR SELECT * FROM shsmd CLOSE DATABASES ALL CLEAR ALL RETURN