SAludos, deseo saber como puedo saber si un determinado campo en excel esta vacio, estoy usando el siguiente codigo:
Código Delphi
[-]procedure TProductoListado.ImportarDatosdesdeExcel1Click(Sender: TObject);
const
xlCellTypeLastCell = $0000000B;
var Libro, hoja : OleVariant;
i:Integer;
id, fila1:String;
begin
OpenDialog1.Execute;
if OpenDialog1.Files.Text<>'' then
if Application.MessageBox('Desea importar el archivo seleccionado?.','Advertencia', MB_YESNO+MB_ICONQUESTION)=IDYES then
begin
i:=1;
Libro:=CreateOleObject('Excel.Application');
Libro.Workbooks.Open(OpenDialog1.FileName);
hoja := Libro.Workbooks[ExtractFileName(OpenDialog1.FileName)].WorkSheets[1];
hoja.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate;
fila1:=hoja.Cells.Item[1,1];
if fila1='ID' then
begin
Medidor.Show;
Medidor.ProgressBar1.Max:=Libro.ActiveCell.Row;
Medidor.ProgressBar1.Step:=1;
for i:=2 to Libro.ActiveCell.Row do
begin
id:=hoja.Cells.Item[i,1];
if id<>''then
begin
if id<>'0' then
begin
IBQConsulta.Close;
IBQConsulta.ParamByName('codigo').AsString:=hoja.Cells.Item[i,2];
IBQConsulta.ParamByName('nombre').AsString:=hoja.Cells.Item[i,4];
IBQConsulta.ParamByName('comprasf').AsFloat:=hoja.Cells.Item[i,6];
IBQConsulta.ParamByName('comprascf').AsFloat:=hoja.Cells.Item[i,7];
IBQConsulta.ParamByName('precioa').AsFloat:=hoja.Cells.Item[i,8];
IBQConsulta.ParamByName('preciob').AsFloat:=hoja.Cells.Item[i,9];
IBQConsulta.ParamByName('precioc').AsFloat:=hoja.Cells.Item[i,10];
IBQConsulta.ParamByName('preciod').AsFloat:=hoja.Cells.Item[i,11];
IBQConsulta.ParamByName('id').AsString:=hoja.Cells.Item[i,1];
IBQConsulta.Open;
end
else
begin
IBQProducto.Close;
IBQProducto.ParamByName('id_categoria').AsString:=hoja.Cells.Item[i,14];
IBQProducto.ParamByName('id_sub_categoria').AsString:='0';
IBQProducto.ParamByName('id_marca').AsString:='0';
IBQProducto.ParamByName('id_medida').AsString:='0';
IBQProducto.ParamByName('codigo').AsString:=hoja.Cells.Item[i,2];
IBQProducto.ParamByName('serie').AsString:=hoja.Cells.Item[i,3];
IBQProducto.ParamByName('nombre').AsString:=hoja.Cells.Item[i,4];
IBQProducto.ParamByName('modelo').AsString:=hoja.Cells.Item[i,5];
IBQProducto.ParamByName('descripcion').AsString:='0';
IBQProducto.ParamByName('preciocsf').AsFloat:=hoja.Cells.Item[i,6];
IBQProducto.ParamByName('precioccf').AsFloat:=hoja.Cells.Item[i,7];
IBQProducto.ParamByName('precioventaa').AsFloat:=hoja.Cells.Item[i,8];
IBQProducto.ParamByName('precioventab').AsFloat:=hoja.Cells.Item[i,9];
IBQProducto.ParamByName('precioventac').AsFloat:=hoja.Cells.Item[i,10];
IBQProducto.ParamByName('precioventad').AsFloat:=hoja.Cells.Item[i,11];
IBQProducto.ParamByName('imagen').AsString:='0';
IBQProducto.ParamByName('observaciones').AsString:='0';
IBQProducto.ParamByName('cantidad_min').AsString:=hoja.Cells.Item[i,12];
IBQProducto.ParamByName('cantidad_max').AsString:=hoja.Cells.Item[i,13];
IBQProducto.ParamByName('activo').AsString:='1';
IBQProducto.ParamByName('servicio').AsString:='0';
IBQProducto.ParamByName('compuesto').AsString:='0';
IBQProducto.Open;
end
end;
Medidor.ProgressBar1.StepIt
end;
IBQProductos.Close;
IBQProductos.Open;
Medidor.Close;
end
else
Application.MessageBox('No se puede importar los datos!.','Error', MB_OK+MB_ICONERROR);
Libro.Quit;
end
end;
Y lo que quiero hacer, es ver si determinado campo no tiene ningun valor. Como puedo hacerlo? Gracias