comobj,Excel97,excel2000을 사용합니다.
//액세스 라이브러리에 액세스하기 위해 Excel의 데이터 쓰기
PRodedure ExcelToMdb(EXL파일:문자열;);
var
시트,XLApp,통합 문서: 변형;
iRow,MaxRow:정수;
시작하다
screen.Cursor:=crHourGlass;
노력하다
//객체 생성
XLApp:=createOleObject('Excel.application');
XLApp.displayAlerts:=false;
XLApp.ScreenUpdating:=false;
XLApp.WorkBooks.Add(EXLfile);
통합 문서 := XLApp.workbooks[1];
시트:=workbook.worksheets[1];
//시트:=XLApp.WorkBooks[1].worksheets[1];
//최대 행 수를 가져옵니다. maxRow
XLApp.ActiveCell.SpecialCells(xlLastCell).Select;
maxRow:=XLApp.ActiveCell.Row; //최대 행 수
//Access 라이브러리에 데이터 쓰기
ADOTable1.open;
iRow:=2에서 MaxRow로 수행
if sheet.cells[iRow,1]<>'' then //키워드가 비어 있지 않습니다.
시작하다
ADOTable1.추가;
ADOTable1.fieldByName('ID').asInteger:=
strToInt(sheet.cells[iRow,1]);
ADOTable1.fieldByName('code').asString:=sheet.cells[iRow,2];//인코딩
ADOTable1.fieldByName('name').asString:=sheet.cells[iRow,3];//name
ADOTable1.post;
끝;
마지막으로
VarIsEmpty(XLApp)가 아닌 경우 시작 //객체 해제
XLApp.displayAlerts:=false;
XLApp.ScreenUpdating:=true;
XLApp.quit;
끝;
screen.Cursor:=crDefault;
끝;
끝;
//==================== 기타 속성 메소드================//
curRow:=XLApp.ActiveCell.Row;//현재 행 수
XLApp.displayAlerts:=false;//매크로 실행 시 경고 및 메시지 표시 여부
XLApp.ScreenUpdating:=false; //화면 업데이트 기능, 속도 향상;
//작업이 끝나면 ScreenUpdating이 다시 True로 설정됩니다.
XLApp.run('macroName',params...)//매크로 실행
통합 문서.저장;
workBook.SaveAs(AFileName,xlNormal,'','',False,False);