Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Exportar de un checklistbox para excel (https://www.clubdelphi.com/foros/showthread.php?t=77845)

Paulao 29-02-2012 15:13:36

Exportar de un checklistbox para excel
 
Como hago para exportar de un checklistbox(los checados) para excel?

kapcomx 01-03-2012 00:18:56

exportar
 
que tal

var
x: integer;
t:string;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0] := true;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0));
ExcelWorksheet1.ConnectTo(ExcelApplication1.Sheets[1] as _WorkSheet);
for x:=0 to checklistbox1.Items.count - 1 do
begin
if (checklistbox1.checked[x]=true) then
begin
t:= checklistbox1.items[x] ;
EXCELWORKSHEET1.Cells.ITEM[x,1].VALUE2:= t;
end;
end;
end;

kapcomx 01-03-2012 00:21:11

exportar
 
que tal paulao, espero te sirva este ejemplo Saludos....:cool:

Código Delphi [-]
var
x: integer; 
t:string;
begin
ExcelApplication1.Connect;
ExcelApplication1.Visible[0] := true;
ExcelWorkbook1.ConnectTo(ExcelApplication1.Workbooks.Add(EmptyParam,0));
ExcelWorksheet1.ConnectTo(ExcelApplication1.Sheets[1] as _WorkSheet);
 for x:=0 to checklistbox1.Items.count - 1  do
    begin
             if (checklistbox1.checked[x]=true) then
            begin
             t:= checklistbox1.items[x]  ;
             EXCELWORKSHEET1.Cells.ITEM[x,1].VALUE2:= t;
            end;
    end;
end;
.

P.D. no se que paso se me repitio mensaje jeje...

Paulao 01-03-2012 14:40:55

No consigo el componente ExcelApplication. Uso Delphi XE 2011.

Paulao 01-03-2012 15:33:18

Voy sacar el Checklistbox y hacer la exportacion directa para excel. Que pasa es que estas mui lento el proceso de busqueda. Yo hizo, creo con la logiva contraria. Yo cargo el nombre de las tablas, sp, view y me voy comparando con los archivos .pas y .dfm. O sea, pego un item y comparo com todas las units(unas 1.400) y despues otro item y hago otra verificacion. O sea, si tengo unos 200 itenes, tengo que hacer 200 veces en cada 1.400 Units. Esto si, es mui demorado. Creo que lo contrario es mas rapido o uno tiene otra solucion? Mi codigo estas ariba.

kapcomx 01-03-2012 17:42:56

codigo
 
¿Cúal Código?, creo que no entendi bien lo que tratas d ehacer...:confused:

Paulao 01-03-2012 18:41:00

Perdon, mi olvide de postar el codigo. Abajo el codigo.
Código Delphi [-]
function TForm1.TextFoundInFile(path: string; const FileMask:string; const tipo, tabela: string): TStrings;
var
  SR: TSearchRec;
  txt: TextFile;
  Row: string;
  Found: Boolean;
  i: Integer;
  NroExt: TStrings;
begin
  NroExt:= TStringList.Create;
  try
    NroExt.Delimiter:= ';';
    NroExt.DelimitedText:= FileMask;
    path := IncludeTrailingPathDelimiter(path);
    Result := TStringList.Create;
    for i:= 0 to NroExt.Count - 1 do
    begin
      if FindFirst(path + NroExt[i], faAnyFile - faDirectory, SR) = 0 then
        repeat
          AssignFile(txt,path + SR.Name);
          Reset(txt);
          Found:= False;
          while not Eof(txt) and not Found do
          begin
            Readln(txt, Row);
            if Pos(tabela, Row) > 0 then
            begin
              Application.ProcessMessages;
              Result.Add(tipo + ';' + tabela + ';' + SR.Name);
              //CheckListBox1.Items.Add(tipo + ' - ' + tabela + ' - ' + SR.Name);
              ListBox1.Items.Add(tipo + ' - ' + tabela + ' - ' + SR.Name);
              Found:= True
            end
          end;
          CloseFile(txt);
        until FindNext(SR) <> 0
    end
  finally
    NroExt.Free;
  end;
end;

y abajo la llamada a este metodo.
Código Delphi [-]
procedure TForm1.VarrerClick(Sender: TObject);
begin
  ClientDataSet1.Open;
  pth := IncludeTrailingPathDelimiter(edtDir.Directory);
  while not ClientDataSet1.Eof do
  begin
    //TextFoundInFile(pth,'*.pas;*.dfm',ClientDataSet1.FieldByName('xtype').AsString,ClientDataSet1.FieldB  yName('name').AsString).SaveToFile('D:\Teste\LISTA.txt');
    TextFoundInFile(pth,'*.pas;*.dfm',ClientDataSet1.FieldByName('xtype').AsString,ClientDataSet1.FieldB  yName('name').AsString);
    ClientDataSet1.Next;
  end;
end;

Paulao 06-03-2012 13:42:31

Tego mas de 1400 archivo(.pas y .dfm) y cargo um nombre y me voy comparando com los textos en eses archivos(.pas y .dfm). Esto esta mui lento mi aplicacion y creo que si yo cambiase la forma de busca creo que mejora, o sea, abri los archivos .pas o .dfm y hacer la comparacion en una lista de los nombres que son unos 200 nombres solo. Pero no se como hacer esto.


La franja horaria es GMT +2. Ahora son las 00:13:28.

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