Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   crear varias tablas en word (https://www.clubdelphi.com/foros/showthread.php?t=95719)

emeritos 14-06-2022 14:02:14

crear varias tablas en word
 
Buenas estoy haciendo desde delphi7 un word y debo de crear varias tablas independiente. Este es mi codigo:

Código PHP:

    Documento := ExtractFilePathApplication.ExeName ) + ficheropdf '.docx';
    
Word.Connect;
    
Word.Documents.Add(EmptyParam,EmptyParam,EmptyParam,EmptyParam);
    
with Word do
        
Begin
          with Selection 
do
              
Begin
                  with Sections
.Item(1).Headers.Item(1).Range do
                      
Begin
                          Font
.Name := 'Arial';
                          
Font.Bold := 1;
                          
Font.Size := 14;
                          
Font.Color := clRed;
                          
Text := 'xxxxxxxxxxxxxxxxxxx ';
                          
Paragraphs.Item(1).Alignment := 1// centramos párrafo
                      
End;


                  
TypeText#13 + #13);
                   
Font.Name := 'Arial';
                   
Font.Size := 14;
                   
Font.Color := clBlack;
                   
Font.Bold := 1;
                   
TypeText'Formación NO Reglada');
                   
Font.Color := clBlue;
                   
Font.Size := 14;
                   
Paragraphs.Item(1).Alignment := 1// centramos párrafo

                   
sw_filastotal := 5;
 
                   
// Insertamos una tabla con fuente de color negro
                   
Font.Color := clBlack;
                   
with Tables.AddRangesw_filastotal3EmptyParamEmptyParam ) do
                              
begin
                                  
// Borde la la tabla
                                  
Borders.Enable := 1;

                                  
// Títulos y ancho de las columnas de la tabla
                                  
Cell(1,1).Range.Text := 'xxxxxxxxx';
                                  
Cell(1,1).Width := 200;
                                  
Cell(1,1).RightPadding;

                                  
Cell(1,2).Range.Text := ' Horas ';
                                  
Cell(1,2).Width := 60;

                                  
Cell(1,3).Range.Text := ' Puntos ';
                                  
Cell(1,3).Width := 60;

                                  
Rows.Item(1).Shading.BackgroundPatternColor := clGreen// fonfo verde
                                  
Rows.Item(1).Range.Font.Color := clYellow// fuente amarilla

                                  
MQreglada.First;
                                  While 
Not MQreglada.Eof do
                                        
Begin
                                            
// Anchura de las Celdas
                                            
Cell(sw_filas,1).Width := 200;
                                            
Cell(sw_filas,2).Width := 60;
                                            
Cell(sw_filas,3).Width := 60;

                                            
// Contenido
                                            
Cell(sw_filas,1).Range.Text := MQreglada['nombrereglada'];
                                            
Cell(sw_filas,2).Range.Text := MQreglada['horas'];
                                            
Cell(sw_filas,3).Range.Text := MQreglada['puntos'];;
                                            
sw_filas := sw_filas 1;
                                            
MQreglada.Next;
                                        
End;
                              
end;



                     
End;
                  
MQreglada.Close;

///// A partir de aqui me lo crea todo en la celda 1,1

                  
TypeText#13 + #13);
                  
Font.Name := 'Arial';
                  
Font.Size := 14;
                  
Font.Color := clBlack;
                  
Font.Bold := 1;
                  
TypeText'dddddddddddddddddddddd');
                  
Font.Color := clBlue;
                  
Font.Size := 14;
                  
with Tables.AddRangesw_filastotal3EmptyParamEmptyParam ) do
                                
begin
                                    
// Borde la la tabla
                                    
Borders.Enable := 1;

                                    
// Títulos y ancho de las columnas de la tabla
                                    
Cell(1,1).Range.Text := 'hhhhhhhhhhhhhhhhh';
                                    
Cell(1,1).Width := 100;
                                    
Cell(1,1).RightPadding;

                                    
Cell(1,2).Range.Text := ' Meses ';
                                    
Cell(1,2).Width := 60;

                                    
Cell(1,3).Range.Text := ' Puntos ';
                                    
Cell(1,3).Width := 60;

                                    
Rows.Item(1).Shading.BackgroundPatternColor := clGreen// fonfo verde
                                    
Rows.Item(1).Range.Font.Color := clYellow// fuente amarilla

                                    
MQexperiencia.First;
                                    While 
Not MQexperiencia.Eof do
                                          
Begin
                                              
// Anchura de las Celdas
                                              
Cell(sw_filas,1).Width := 100;
                                              
Cell(sw_filas,2).Width := 60;
                                              
Cell(sw_filas,3).Width := 60;

                                              
// Contenido
                                              
Cell(sw_filas,1).Range.Text := MQexperiencia['nombreexperiencia'];
                                              
Cell(sw_filas,2).Range.Text := MQexperiencia['meses'];
                                              
Cell(sw_filas,3).Range.Text := MQexperiencia['puntos'];;
                                              
sw_filas := sw_filas 1;
                                              
MQexperiencia.Next;
                                          
End;
                                
end;
                     
End;
                  
MQexperiencia.Close;

              
End;
        
End;


    
// Grabar y cerra documento
    
Word.ActiveDocument.SaveAsDocumento,
      
EmptyParamEmptyParamEmptyParamEmptyParamEmptyParamEmptyParam,
      
EmptyParamEmptyParamEmptyParamEmptyParamEmptyParamEmptyParam,
      
EmptyParamEmptyParamEmptyParam );
    
Word.Quit;
    
Word.Disconnect;
    
Word.Free

Lo primero es que la primera tabla me la crea bien y la segunda me la coloca en la celda (1,1) (junto tambien al su encabezado), de la primera tabla y no se distinguir entre la primera y la segunda aunque no es importante por que lo que quiero es crearla una debajo de la otra.

Gracias.


La franja horaria es GMT +2. Ahora son las 06:07:35.

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