[此贴子已经被作者于2024-4-28 18:58编辑过]
cDefPath = ADDBS(JUSTPATH(SYS(16))) SET DEFAULT TO (cDefPath) excel = CREATEOBJECT("Excel.Application") excel.DisplayAlerts = 0 excel.WorkBooks.Add excel.Cells(1,1) = "姓名" excel.Cells(1,2) = "性别" excel.Cells(1,3) = "身份证号" excel.Cells(1,4) = "籍贯" excel.Cells(1,5) = "语文" excel.Cells(1,6) = "数学" excel.Cells(1,7) = "英语" excel.Cells(1,8) = "历史" excel.Columns("A:H").HorizontalAlignment = -4108 excel.Columns("C:C").NumberFormatLocal = "@" word = CREATEOBJECT("Word.Application") FOR i=1 TO ADIR(aDocx,"*.docx") doc = word.Documents.Open(cDefPath+aDocx[i,1]) tab = doc.tables[1] excel.Cells(i+1,1) = RTRIM(tab.Cell(1,2).Range.Text,0h0D,0h07,0h20) excel.Cells(i+1,2) = RTRIM(tab.Cell(1,4).Range.Text,0h0D,0h07,0h20) excel.Cells(i+1,3) = RTRIM(tab.Cell(2,2).Range.Text,0h0D,0h07,0h20) excel.Cells(i+1,4) = RTRIM(tab.Cell(3,2).Range.Text,0h0D,0h07,0h20) excel.Cells(i+1,5) = VAL(tab.Cell(4,2).Range.Text) excel.Cells(i+1,6) = VAL(tab.Cell(4,4).Range.Text) excel.Cells(i+1,7) = VAL(tab.Cell(5,2).Range.Text) excel.Cells(i+1,8) = VAL(tab.Cell(5,4).Range.Text) doc.Close ENDFOR word.Quit #define xlOpenXMLWorkbook 51 excel.ActiveWorkbook.SaveAs(cDefPath+"学生考试成绩信息表.xlsx", xlOpenXMLWorkbook) excel.Workbooks.Close excel.Quit