Impimer de grid

Résolu
souilahmedali Messages postés 8 Date d'inscription lundi 20 octobre 2008 Statut Membre Dernière intervention 6 mai 2009 - 6 mai 2009 à 00:01
souilahmedali Messages postés 8 Date d'inscription lundi 20 octobre 2008 Statut Membre Dernière intervention 6 mai 2009 - 6 mai 2009 à 16:44
je veut imprimer une table vfp déjà affichée sur une grid
j'ai trouvé quelque code mais ça se marche pas

4 réponses

souilahmedali Messages postés 8 Date d'inscription lundi 20 octobre 2008 Statut Membre Dernière intervention 6 mai 2009
6 mai 2009 à 05:22
je le rouve en fin

#DEFINE wdToggle 9999998
#DEFINE wdTableRight -999996
#DEFINE wdAlignParagraphLeft 0
#DEFINE wdAlignParagraphCenter 1
#DEFINE wdAlignParagraphJustify 3
#DEFINE wdHorizontalPositionMargin 0
#DEFINE wdCollapseEnd 0
#DEFINE wdCollapseStart 1
#DEFINE wdParagraph 4

oWord = CREATEOBJECT("Word.Application")
oWord.Visible = .F.  && Toggle this to True to see if there's
                     && any difference
oDoc = oWord.Documents.Add()
oRange = oDoc.Range()
oRange.Collapse(wdCollapseStart)
*!*    WITH oRange
*!*        .ParagraphFormat.Alignment = wdAlignParagraphCenter
*!*        .Font.Size = 14
*!*        .Font.Name = "Arial Black"
*!*        .InsertAfter("Heading for Sales Report")
*!*        .MoveEnd(wdParagraph,1)

*!*        .Bold = .T.
*!*        .Collapse(wdCollapseEnd)
*!*        .InsertParagraphAfter()
*!*        .MoveEnd(wdParagraph,1)
*!*        .Bold = .F.
*!*        .Collapse(wdCollapseEnd)

*!*        .ParagraphFormat.Alignment = wdAlignParagraphLeft
*!*        .Font.Size = 12
*!*        .Font.Name = "Times New Roman"
*!*        .InsertParagraphAfter()
*!*        .InsertParagraphAfter()
*!*        .ParagraphFormat.Alignment = wdAlignParagraphLeft
*!*        .InsertAfter(REPLICATE("Paragraph #1 is left aligned. "+;
*!*            "Paragraph 2 is justified. ",4))
*!*        .Collapse(wdCollapseEnd)
*!*        .InsertParagraphAfter()
*!*        .InsertParagraphAfter()
*!*        .Collapse(wdCollapseEnd)
*!*        .ParagraphFormat.Alignment = wdAlignParagraphJustify
*!*        .InsertAfter(REPLICATE("This is a long paragraph that "+;
*!*            "needs to wrap around a table that will fit in the "+;
*!*            "paragraph, aligned at the right margin. ", 3))
*!*        .Collapse(wdCollapseEnd)
*!*    ENDwith

*!* Need a table of 4 rows, 3 columns, plus cells for labels and headings.
oWord.ActiveDocument.Tables.Add(oRange, 5, 3, 1, 0) && Word 2000 syntax
*!* Arguments are Range, #rows, #cols, [DefaultTableBehavior,] [AutoFitBehavior])
*!* Word 97 syntax is oWord.ActiveDocument.Tables.Add(oRange, 5, 4)
oTable = oWord.ActiveDocument.Tables(1) && Assign a table object
WITH oTable
    .Columns.SetWidth(72,0)               && 72 points/inch
    .Rows.WrapAroundText = .T.
    .Rows.RelativeHorizontalPosition = 0  && wdHorizontalPositionMargin
    .Rows.HorizontalPosition = -999996    && wdTableRight
    .Autoformat(2,.T.,.T.,.T.,.T.,.T.,.T.,.T.,.T.,.T.)
*!* (Format,ApplyBorders,ApplyShading,ApplyFont,ApplyColor,ApplyHeadingRows,
*!*         ApplyLastRow,ApplyFirstColumn,ApplyLastColumn,AutoFit)
 *!*================ selectio de table en curseur
SELECT * FROM upcmd INTO CURSOR wd
n=2
    .Cell(1,1).Range.InsertAfter("num ligne")
    .Cell(1,2).Range.InsertAfter("cod articl")
    .Cell(1,3).Range.InsertAfter("nom articl")
 scan
    .Cell(n,1).Range.InsertAfter(STR(wd.cod_ligne))
    .Cell(n,2).Range.InsertAfter(STR(wd.cod_articl))
    .Cell(n,3).Range.InsertAfter(wd.nom_articl)
n=n+1
endscan
ENDwith
oRange = oTable.Range
oRange.Collapse(wdCollapseEnd) && Move insertion point beyond table
*!*    WITH oRange
*!*        .InsertAfter("The table goes before this sentence. ")
*!*        .InsertAfter(REPLICATE("This is a long paragraph that "+;
*!*            "needs to wrap around a table that will fit in the "+;
*!*            "paragraph, aligned at the right margin. ",5))
*!*        .InsertParagraphAfter()
*!*        .InsertParagraphAfter()
*!*        .InsertAfter("A New Paragraph")
*!*    ENDwith

oWord.Visible = .T.  && Inspect the results
MESSAGEBOX("Look at results in Word.")

&&oWord.Quit(.F.) && Don't save changes
ThisForm.Release
3
souilahmedali Messages postés 8 Date d'inscription lundi 20 octobre 2008 Statut Membre Dernière intervention 6 mai 2009
6 mai 2009 à 00:04
exemple de code:

 ************* Beginning of code. ****************

   PUBLIC oWord
    oWord = CREATEOBJECT("Word.Basic")
    WITH oWord
       .AppShow        && Makes Word Visible
       .FileNewDefault && Opens up blank Word document

       * The following Insert commands place the FoxPro fields into
       * the Word document. You can change these commands to place
       * any text in the document.
       * Ensure that the table is already open. If only a portion
       * of records are to be printed, change the EOF() to a certain
       * number so that all of the records do not get processed.
       * Example: DO WHILE RECNO() < 10

       GO TOP

       DO WHILE NOT EOF()
          .Insert("Record: "+ALLTRIM(STR(RECNO())))
            && The above line shows the record number.
          .InsertPara
          .InsertPara
          .Insert(ALLTRIM(nom))   && Field in the table.
          .InsertPara
              .Insert(address)
              .InsertPara
              .Insert(ALLTRIM(city)+", "+state+"  "+zipcode)
              .InsertPara
              .InsertPara
              .Insert("Contents of the General Field:")
              .InsertPara
              .InsertPara
           KEYBOARD "{ctrl+c} {ctrl+w}" && Copies and closes the general
                                        && field to the clipboard.
           MODIFY GENERAL gen           && This has to be after the
                                        && KEYBOARD command.
          .EditPaste
          .WordLeft(1,1)
          .EditObject("0")
          .EditSelectAll
          .Editcopy
          .FileClose
          .EditClear
          .EditPaste
          .InsertPara
          .InsertPara
          .InsertPara
           SKIP                     && Move the record pointer to
                                    && the next record.
       ENDDO
       .FileSaveAs("c:\mydoc.doc")  && Saves the Word document as
                                    && Mydoc.doc.
          .FilePrint
       .AppClose
    ENDWITH
  

**************** End of code. ****************
0
michelatoutfox Messages postés 828 Date d'inscription mardi 5 octobre 2004 Statut Membre Dernière intervention 7 mai 2013 1
6 mai 2009 à 07:25
Et un report tout simple, ça ne convenait pas?
0
souilahmedali Messages postés 8 Date d'inscription lundi 20 octobre 2008 Statut Membre Dernière intervention 6 mai 2009
6 mai 2009 à 16:44
oui,merçi.
0
Rejoignez-nous