D
downage
Unregistered / Unconfirmed
GUEST, unregistred user!
运行到加粗的那行就出这个错误,谢谢!
procedure TForm1.ExcelToMdb(EXLfile: string);
var
sheet,XLApp,workbook:variant;
iRow,MaxRow:integer;
begin
screen.Cursor:=crHourGlass;
try
//创建对象
XLApp:=createOleObject('Excel.Application');
XLApp.displayAlerts:=false;
XLApp.ScreenUpdating:=false;
XLApp.WorkBooks.Add(EXLfile);
workbook:=XLApp.workbooks[1];
sheet:=workbook.worksheets[1];
//sheet:=XLApp.WorkBooks[1].worksheets[1];
//取得最大行数 maxRow
XLApp.ActiveCell.SpecialCells(xlLastCell).Select;
maxRow:=XLApp.ActiveCell.Row
//最大行数
//label1.Caption:=inttostr(maxrow);
//写数据到Access库
adotable1.open;
for iRow:=2 to MaxRow do
begin
showmessage(inttostr(iRow));
if sheet.cells[iRow,1]<>'' then//关键字不为空
begin
adotable1.Append;
label1.Caption:=inttostr(iRow);
adotable1.fieldByName('cp_xinghao').asString:=sheet.cells[iRow,1];
//adotable1.fieldByName('cp_shuliang').asInteger:=strToInt(sheet.cells[iRow,2]);
adotable1.fieldByName('cp_shuliang').asInteger:=123123 ;
procedure TForm1.ExcelToMdb(EXLfile: string);
var
sheet,XLApp,workbook:variant;
iRow,MaxRow:integer;
begin
screen.Cursor:=crHourGlass;
try
//创建对象
XLApp:=createOleObject('Excel.Application');
XLApp.displayAlerts:=false;
XLApp.ScreenUpdating:=false;
XLApp.WorkBooks.Add(EXLfile);
workbook:=XLApp.workbooks[1];
sheet:=workbook.worksheets[1];
//sheet:=XLApp.WorkBooks[1].worksheets[1];
//取得最大行数 maxRow
XLApp.ActiveCell.SpecialCells(xlLastCell).Select;
maxRow:=XLApp.ActiveCell.Row
//最大行数
//label1.Caption:=inttostr(maxrow);
//写数据到Access库
adotable1.open;
for iRow:=2 to MaxRow do
begin
showmessage(inttostr(iRow));
if sheet.cells[iRow,1]<>'' then//关键字不为空
begin
adotable1.Append;
label1.Caption:=inttostr(iRow);
adotable1.fieldByName('cp_xinghao').asString:=sheet.cells[iRow,1];
//adotable1.fieldByName('cp_shuliang').asInteger:=strToInt(sheet.cells[iRow,2]);
adotable1.fieldByName('cp_shuliang').asInteger:=123123 ;