Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Coloboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 18-01-2010
sonjeux sonjeux is offline
Miembro
 
Registrado: jul 2004
Posts: 60
Poder: 21
sonjeux Va por buen camino
Importar desde Excel campo vacio

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;
      //Hoja : _WORKSHEET;
      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:=ExcelApplication1.Workbooks.Open('c:\productos.xls', EmptyParam, EmptyParam, EmptyParam,
                                         EmptyParam, EmptyParam, EmptyParam, EmptyParam,
                                         EmptyParam, EmptyParam, EmptyParam, EmptyParam,
                                         EmptyParam, EmptyParam, EmptyParam, 0);*)
         Libro.Workbooks.Open(OpenDialog1.FileName);

         hoja := Libro.Workbooks[ExtractFileName(OpenDialog1.FileName)].WorkSheets[1];
         hoja.Cells.SpecialCells(xlCellTypeLastCell, EmptyParam).Activate;

         //ShowMessage(IntToStr(Libro.ActiveCell.Row));

         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;
               //IBProducto.Refresh;
               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
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Como importar datos desde Excel? axlrafael Servers 50 18-10-2012 13:38:14
Insertar imagen desde campo blob en excel David OOP 1 18-03-2009 18:30:34
importar datos desde excel voldemmor Firebird e Interbase 3 03-02-2009 23:40:56
Importar desde Excel Lucas_diaz1810 Conexión con bases de datos 5 03-11-2006 18:15:26
Importar desde Excel LucasArgentino SQL 1 24-12-2003 17:33:26


La franja horaria es GMT +2. Ahora son las 18:19:46.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi