Information générale
Catégorie:
COM/DCOM et OLE Automation
Here is some code to study. The answer is in here somewhere. This code creates a table and inserts values in each cell. Good Luck!
================================================================================
LPARAMETERS oThisform, cPercentage
#INCLUDE excel97.h
#INCLUDE WORD2000.h
cstoreno=alltrim(clntstore.store_no)
ccategcode=category.categcode
orange.collapse(wdcollapseend)
orange.MoveEnd(wdStory)
orange.Style=onormalstyle
orange.font.size=1
orange.InsertAfter(replicate(cr,1))
orange.collapse(wdcollapseend)
orange.Style=oSubTitle1
orange.ParagraphFormat.Alignment = wdalignparagraphleft
orange.insertafter(category.subTitle+cr)
orange.MoveEnd(wdStory)
orange.collapse(wdcollapseend)
Do insertsmall with 1,2
select tmpFinalResults
set order to QUESTION3
locate
orange.MoveEnd(wdStory)
orange.collapse(wdcollapseend)
nTableRow=1
oTable=odocument.Tables.Add(oRange, 1, 8, 0, 0)
oTable.AllowPageBreaks=.T.
oTable.AllowAutoFit=.T.
oTable.Borders.InsideLineStyle=.F.
oTable.Borders.OutsideLineStyle=.F.
oTable.Rows[nTableRow].HeightRule=1
oTable.Rows[nTableRow].Height=10
oTableRange=oTable.Rows[nTableRow].Range()
oTableRange.Cells.VerticalAlignment=wdAlignVerticalBottom
With oTableRange
.cells[1].Range.Select()
.cells[1].Width=190
.Cells[1].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[1].Range.Font.Italic=.F.
.Cells[1].Range.Font.Size=10
.Cells[1].Range.Bold=.T.
.cells[1].Range.collapse(wdcollapseend)
.cells[2].Range.Select()
.cells[2].Width=40
.Cells[2].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[2].Range.Font.Italic=.F.
.Cells[2].Range.Font.Size=10
.Cells[2].Range.Bold=.T.
.Cells[2].Range.insertafter("")
** .Cells[2].Borders[wdBorderRight].LineStyle=wdLineStyleSingle
.cells[2].Range.collapse(wdcollapseend)
.cells[3].Range.Select()
.cells[3].Width=40
.Cells[3].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[3].Range.Font.Italic=.F.
.Cells[3].Range.Font.Size=10
.Cells[3].Range.Bold=.T.
.Cells[3].Range.insertafter("Excellent")
.Cells[3].Borders[wdBorderBottom].LineStyle=wdLineStyleSingle
.cells[3].Range.collapse(wdcollapseend)
.cells[4].Range.Select()
.cells[4].Width=40
.Cells[4].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[4].Range.Font.Italic=.F.
.Cells[4].Range.Font.Size=10
.Cells[4].Range.Bold=.T.
.Cells[4].Range.insertafter("Very Good")
.Cells[4].Borders[wdBorderBottom].LineStyle=wdLineStyleSingle
.cells[4].Range.collapse(wdcollapseend)
.cells[5].Range.Select()
.cells[5].Width=40
.Cells[5].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[5].Range.Font.Italic=.F.
.Cells[5].Range.Font.Size=10
.Cells[5].Range.Bold=.T.
.Cells[5].Range.insertafter("Good")
.Cells[5].Borders[wdBorderBottom].LineStyle=wdLineStyleSingle
.cells[5].Range.collapse(wdcollapseend)
.cells[6].Range.Select()
.cells[6].Width=40
.Cells[6].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[6].Range.Font.Italic=.F.
.Cells[6].Range.Font.Size=10
.Cells[6].Range.Bold=.T.
.Cells[6].Range.insertafter("Fair")
.Cells[6].Borders[wdBorderBottom].LineStyle=wdLineStyleSingle
.cells[6].Range.collapse(wdcollapseend)
.cells[7].Range.Select()
.cells[7].Width=40
.Cells[7].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[7].Range.Font.Italic=.F.
.Cells[7].Range.Font.Size=10
.Cells[7].Range.Bold=.T.
.Cells[7].Range.insertafter("Poor")
.Cells[7].Borders[wdBorderBottom].LineStyle=wdLineStyleSingle
.cells[7].Range.collapse(wdcollapseend)
.cells[8].Range.Select()
.cells[8].Width=40
.Cells[8].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[8].Range.Font.Italic=.F.
.Cells[8].Range.Font.Size=10
.Cells[8].Range.Bold=.T.
.Cells[8].Range.insertafter("Base")
.Cells[8].Borders[wdBorderBottom].LineStyle=wdLineStyleSingle
.cells[8].Range.collapse(wdcollapseend)
Endwith
nCntQuest=1
cQuestion=" "
LOCATE
do while .not. eof()
cQuestion=question
lFirstTime=.T.
nCntQuest=1
nTableRow=nTableRow+1
oTable.Rows.Add()
oTableRange=oTable.Rows[nTableRow].Range()
oTableRange.Cells.VerticalAlignment=wdAlignVerticalTop
** oTableRange.Select()
oTable.Rows[nTableRow].HeightRule=1
oTable.Rows[nTableRow].Height=9
oTable.Rows[nTableRow].Borders[wdBorderBottom].LineStyle=wdLineStyleNone
do while question == cQuestion
cYear=Year
scan while question == cQuestion and year==cYear
With oTableRange
IF lFirstTime
.cells[1].Range.Select()
.Cells[1].Range.ParagraphFormat.Alignment = wdAlignParaGraphRight
.Cells[1].Range.Font.Italic=.F.
.Cells[1].Range.Font.Size=10
.Cells[1].Range.Bold=.F.
.Cells[1].Range.insertafter(alltrim(quest_txt))
.cells[1].Range.collapse(wdcollapseend)
ENDIF
nCurYear=INT(VAL(Year))
cCurYearRange=RIGHT(alltrim(STR(nCurYear,4,0)),2)+"/"+RIGHT(alltrim(STR(nCurYear+1,4,0)),2)
.cells[2].Range.Select()
.Cells[2].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[2].Range.Font.Italic=.F.
.Cells[2].Range.Font.Size=10
.Cells[2].Range.Bold=.F.
.Cells[2].Range.insertafter(cCurYearRange+IIF(lFirstTime,cr,''))
.Cells[2].Borders[wdBorderRight].LineStyle=wdLineStyleSingle
.cells[2].Range.collapse(wdcollapseend)
.cells[3].Range.Select()
.Cells[3].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[3].Range.Font.Italic=.F.
.Cells[3].Range.Font.Size=10
.Cells[3].Range.Bold=.F.
.Cells[3].Range.insertafter(TRANSFORM(Excellent,'@R 999%')+IIF(lFirstTime,cr,''))
if nTableRow = 2
.cells[3].Borders[wdBorderTop].linestyle=wdLineStyleSingle
else
.cells[3].Borders[wdBorderTop].linestyle=wdLineStyleNone
endif
.cells[3].Range.collapse(wdcollapseend)
.cells[4].Range.Select()
.Cells[4].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[4].Range.Font.Italic=.F.
.Cells[4].Range.Font.Size=10
.Cells[4].Range.Bold=.F.
.Cells[4].Range.insertafter(TRANSFORM(VeryGood,'@R 999%')+IIF(lFirstTime,cr,''))
if nTableRow =2
.cells[4].Borders[wdBorderTop].linestyle=wdLineStyleSingle
else
.cells[4].Borders[wdBorderTop].linestyle=wdLineStyleNone
endif
.cells[4].Range.collapse(wdcollapseend)
.cells[5].Range.Select()
.Cells[5].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[5].Range.Font.Italic=.F.
.Cells[5].Range.Font.Size=10
.Cells[5].Range.Bold=.F.
.Cells[5].Range.insertafter(TRANSFORM(Good,'@R 999%')+IIF(lFirstTime,cr,''))
if nTableRow = 2
.cells[5].Borders[wdBorderTop].linestyle=wdLineStyleSingle
else
.cells[5].Borders[wdBorderTop].linestyle=wdLineStyleNone
endif
.cells[5].Range.collapse(wdcollapseend)
.cells[6].Range.Select()
.Cells[6].Range.ParagraphFormat.Alignment = wdalignparagraphright
.Cells[6].Range.Font.Italic=.F.
.Cells[6].Range.Font.Size=10
.Cells[6].Range.Bold=.F.
.Cells[6].Range.insertafter(TRANSFORM(Fair,'@R 999%')+IIF(lFirstTime,cr,''))
if nTableRow = 2
.cells[6].Borders[wdBorderTop].linestyle=wdLineStyleSingle
else
.cells[6].Borders[wdBorderTop].linestyle=wdLineStyleNone
endif
.cells[6].Range.collapse(wdcollapseend)
.cells[7].Range.Select()
.Cells[7].Range.ParagraphFormat.Alignment = wdAlignparagraphright
.Cells[7].Range.Font.Italic=.F.
.Cells[7].Range.Font.Size=10
.Cells[7].Range.Bold=.F.
.Cells[7].Range.insertafter(TRANSFORM(Poor,'@R 999%')+IIF(lFirstTime,cr,''))
if nTableRow = 2
.cells[7].Borders[wdBorderTop].linestyle=wdLineStyleSingle
else
.cells[7].Borders[wdBorderTop].linestyle=wdLineStyleNone
endif
.cells[7].Range.collapse(wdcollapseend)
.cells[8].Range.Select()
.Cells[8].Range.ParagraphFormat.Alignment = wdAlignparagraphright
.Cells[8].Range.Font.Italic=.F.
.Cells[8].Range.Font.Size=10
.Cells[8].Range.Bold=.F.
.Cells[8].Range.insertafter(TRANSFORM(Base,'9999')+IIF(lFirstTime,cr,''))
if nTableRow = 2
.cells[8].Borders[wdBorderTop].linestyle=wdLineStyleSingle
else
.cells[8].Borders[wdBorderTop].linestyle=wdLineStyleNone
endif
.cells[8].Range.collapse(wdcollapseend)
if lFirstTime
lFirstTime=.F.
endif
Endwith
EndScan
nCntQuest=nCntQuest+1
Enddo
oTable.Rows.Add()
nTableRow=nTableRow+1
oTableRange=oTable.Rows[nTableRow].Range()
oTableRange.Select()
oTable.Rows[nTableRow].HeightRule=2
oTable.Rows[nTableRow].Height=5
oTable.Rows[nTableRow].Borders[wdBorderBottom].LineStyle=wdLineStyleNone
oTable.Rows[nTableRow].Borders[wdBorderTop].LineStyle=wdLineStyleNone
Enddo
oRange.MoveEnd(wdStory)
oRange.collapse(wdcollapseend)
Select tmpresults1
Use
Select tmpresults2
Use
Select tmpresults3
Use
Select tmpfinalresults
Use
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement