OpenDialog1.Execute then
Archivo.Text:=OpenDialog1.FileName;
If Archivo.Text<>'' then
Begin
Screen.Cursor := crHourGlass;
LimpiarStringGrid();
SpeedButton5.Enabled :=false;
SpeedButton2.Enabled :=false;
try
Excel := CreateOleObject('Excel.Application');
except
Excel.Quit;
showmessage('No se pudo crear el Objecto Excel.');
raise;
end;
Try
salida:=false;
Excel.Workbooks.Open(Archivo.text);
j:=2; f:=1;
str:= Excel.Cells[j,1].Value; if (str='')then
salida:=true;
While not salida do
begin
StringGrid1.Cells[0,f]:= Excel.Cells[j,1].Value; StringGrid1.Cells[1,f]:= Excel.Cells[j,2].Value; StringGrid1.Cells[2,f]:= Excel.Cells[j,3].Value; StringGrid1.Cells[3,f]:= Excel.Cells[j,4].Value; StringGrid1.Cells[4,f]:= Excel.Cells[j,5].Value; StringGrid1.Cells[5,f]:= Excel.Cells[j,6].Value; StringGrid1.Cells[6,f]:= Excel.Cells[j,7].Value; StringGrid1.Cells[7,f]:= Excel.Cells[j,8].Value; StringGrid1.Cells[8,f]:= Excel.Cells[j,9].Value; StringGrid1.Cells[9,f]:= Excel.Cells[j,10].Value;
StringGrid1.Cells[10,f]:= Excel.Cells[j,11].Value; StringGrid1.Cells[11,f]:= Excel.Cells[j,12].Value; StringGrid1.Cells[12,f]:= Excel.Cells[j,13].Value; StringGrid1.Cells[13,f]:= Excel.Cells[j,14].Value; StringGrid1.Cells[14,f]:= Excel.Cells[j,15].Value; StringGrid1.Cells[15,f]:= Excel.Cells[j,16].Value; StringGrid1.Cells[16,f]:= Excel.Cells[j,17].Value; StringGrid1.Cells[17,f]:= Excel.Cells[j,18].Value; StringGrid1.Cells[18,f]:= Excel.Cells[j,19].Value; StringGrid1.Cells[19,f]:= Excel.Cells[j,20].Value;
StringGrid1.Cells[20,f]:= Excel.Cells[j,21].Value; StringGrid1.Cells[21,f]:= Excel.Cells[j,22].Value; StringGrid1.Cells[22,f]:= Excel.Cells[j,23].Value; StringGrid1.Cells[23,f]:= Excel.Cells[j,24].Value; StringGrid1.Cells[24,f]:= Excel.Cells[j,25].Value; StringGrid1.Cells[25,f]:= Excel.Cells[j,26].Value; StringGrid1.Cells[26,f]:= Excel.Cells[j,27].Value; StringGrid1.Cells[27,f]:= Excel.Cells[j,28].Value; StringGrid1.Cells[28,f]:= Excel.Cells[j,29].Value; StringGrid1.Cells[29,f]:= Excel.Cells[j,30].Value;
StringGrid1.Cells[30,f]:= Excel.Cells[j,31].Value; StringGrid1.Cells[31,f]:= Excel.Cells[j,32].Value; StringGrid1.Cells[32,f]:= Excel.Cells[j,33].Value; StringGrid1.Cells[33,f]:= Excel.Cells[j,34].Value; StringGrid1.Cells[34,f]:= Excel.Cells[j,35].Value; StringGrid1.Cells[35,f]:= Excel.Cells[j,36].Value; StringGrid1.Cells[36,f]:= Excel.Cells[j,37].Value; StringGrid1.Cells[37,f]:= Excel.Cells[j,38].Value; StringGrid1.Cells[38,f]:= Excel.Cells[j,39].Value; StringGrid1.Cells[39,f]:= Excel.Cells[j,40].Value;
StringGrid1.Cells[40,f]:= Excel.Cells[j,41].Value; StringGrid1.Cells[41,f]:= Excel.Cells[j,42].Value; StringGrid1.Cells[42,f]:= Excel.Cells[j,43].Value; StringGrid1.Cells[43,f]:= Excel.Cells[j,44].Value; StringGrid1.Cells[44,f]:= Excel.Cells[j,45].Value; StringGrid1.Cells[45,f]:= Excel.Cells[j,46].Value; StringGrid1.Cells[46,f]:= Excel.Cells[j,47].Value; StringGrid1.Cells[47,f]:= Excel.Cells[j,48].Value; StringGrid1.Cells[48,f]:= Excel.Cells[j,49].Value; StringGrid1.Cells[49,f]:= Excel.Cells[j,50].Value;
StringGrid1.Cells[50,f]:= Excel.Cells[j,51].Value; StringGrid1.Cells[51,f]:= Excel.Cells[j,52].Value; StringGrid1.Cells[52,f]:= Excel.Cells[j,53].Value; StringGrid1.Cells[53,f]:= Excel.Cells[j,54].Value; StringGrid1.Cells[54,f]:= Excel.Cells[j,55].Value; StringGrid1.Cells[55,f]:= Excel.Cells[j,56].Value; StringGrid1.Cells[56,f]:= Excel.Cells[j,57].Value; StringGrid1.Cells[57,f]:= Excel.Cells[j,58].Value; StringGrid1.Cells[58,f]:= Excel.Cells[j,59].Value;
StringGrid1.RowCount:=StringGrid1.RowCount+1; inc(j);
inc(f);
str:= Excel.Cells[j,1].Value;
if (str='')then
salida:=true;
end;
Excel.Quit;
except
begin
Excel.Quit;
ShowMessage(' !!!!! ATENCION !!!!! ' + chr(13) +' El fichero no pudo ser importado' + chr(13) +' Revise bien su estructura');
end;
End;
End;
SpeedButton5.Enabled :=true;
SpeedButton2.Enabled :=true;
Screen.Cursor := crDefault;