[firebase-br] Conversão de dados 2

Everton Patricio everton.patricio01 em uol.com.br
Ter Ago 25 16:41:29 -03 2009


De antemão obrigado pelo retorno,

 
A linguagem que estou utilizando é delphi. Realmente terei que importar os dados, inclusive já conseguí um artigo relacionado como o demonstro a seguir:



----------

procedure TForm1.Button2Click(Sender: TObject);
var
  I: Integer;
  Nome: string;
  Capital: string;
  Continente: string;
  Area: string;
  Populacao: string;
begin
  { Criar arquivo Excel }
  { Pega o usuário logado }
  LCID := GetUserDefaultLCID;
  { Torna a aplicação visível }
  ExcelApplication1.Visible[LCID] := True;
  { Remove alertas do excel }
  ExcelApplication1.DisplayAlerts[LCID] := False;
  { Cria o novo arquivo }
  WKBK := ExcelApplication1.Workbooks.Open(
    ExtractFilePath(Application.ExeName) +
    'country.xls', EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam,
    EmptyParam, LCID);

  { Conecta a planilha (1) que será a planilha a 
receber os dados }
  ExcelWorksheet1.ConnectTo(WKBK.Worksheets[1] as _Worksheet);
  { Ativa a planilha conectada }
  ExcelWorksheet1.Activate(LCID);
  { Torna possível fazer alterações }
  ExcelApplication1.ScreenUpdating[LCID] := True;

  with ClientDataSet1, ExcelWorksheet1 do 
  begin
    Open;
    EmptyDataSet;
    for I := 2 to Rows.Count do
    begin  
      Nome := Range['A' + IntToStr(I), 'A' + IntToStr(I)].Value2;
      Capital := Range['B' + IntToStr(I), 'B' + IntToStr(I)].Value2;
      Continente := Range['C' + IntToStr(I), 'C' + IntToStr(I)].Value2;
      Area := Range['D' + IntToStr(I), 'D' + IntToStr(I)].Value2;
      Populacao := Range['E' + IntToStr(I), 'E' + IntToStr(I)].Value2;

      if not ((Trim(Nome) = '') and (Trim(Capital) = '') and
        (Trim(Continente) = '') and (Trim(Area) = '') and
        (Trim(Populacao) = '')) then 
      begin    
        ClientDataSet1.Append;
        ClientDataSet1.FieldByName('NAME').AsString := Nome;
        ClientDataSet1.FieldByName('CAPITAL').AsString := Capital;
        ClientDataSet1.FieldByName('Continent').AsString := Continente;
        ClientDataSet1.FieldByName('Area').AsString := Area;
        ClientDataSet1.FieldByName('Population').AsString := Populacao;
        ClientDataSet1.Post;
      end
      else
        Break;
    end; 
  end;
  ShowMessage('A importação foi realizada com êxito.');
end;


-------

O artigo completo pode ser encontrado em:
http://delphitodelphi.blogspot.com/2008/11/pessoal-muitas-pessoas-tem-me-enviado-e.html

O problema, neste caso, é que não consigo encontrar a unit (a Unit Excel97 ) para que o código possa compilar.

Agradecimentos, Everton.




Mais detalhes sobre a lista de discussão lista