if FileExists(dfile) then begin excelapplication1.Workbooks.Open(dfile, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0); ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]); ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets['sheet1'] as _Worksheet); advstringgrid1.ColCount := 20; for i := 1 to 600 do begin for j := 1 to 22 do begin if trim(excelworksheet1.cells.item[i + 1, 1]) <> '' then begin advstringgrid1.rowCount := i + 1; advstringgrid1.Cells[j - 1, i - 1] := ExcelWorksheet1.Cells.Item[i, j]; Application.ProcessMessages; end else break; end; end; excelapplication1.Quit; ExcelApplication1.Disconnect; // DeleteFile(dfile); end;
excelapplication1.Workbooks.Open(dfile,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
EmptyParam, EmptyParam, EmptyParam, EmptyParam, 0);
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks[1]);
ExcelWorksheet1.ConnectTo(ExcelWorkbook1.Worksheets['sheet1'] as _Worksheet);
advstringgrid1.ColCount := 20;
for i := 1 to 600 do begin
for j := 1 to 22 do begin
if trim(excelworksheet1.cells.item[i + 1, 1]) <> '' then begin
advstringgrid1.rowCount := i + 1;
advstringgrid1.Cells[j - 1, i - 1] := ExcelWorksheet1.Cells.Item[i, j];
Application.ProcessMessages;
end else
break;
end;
end;
excelapplication1.Quit;
ExcelApplication1.Disconnect;
// DeleteFile(dfile);
end;