>Hi, everyone
>
>I want to generate a PRICE LIST from my database into EXCEL file format.
>I coding below command as below :-
>
>EXCEL_FILE.APPLICATION.CELLS(1,4).VALUE = "ITEM NO. : " + PRO_CODE
>
>now... i want to put a photo into CELLS(1,5), the photo was stord in database.field [MyProduct.photo]
>
>How ???
>
>I make it, cause i want to send the Price List (Excel) to my client with photo. If the Excel is not the best ways, what suggest for ?
Hs,
Honestly I would go with an HTML file. HTML or Excel your main problem is to get embedded pictures back as image files. To do that there are several ways and one is to copy general field to another temp table record by record, open its fpt lowlevel and get portion after offset 599. Or alternatively you could use copy from general and paste in excel too.
Assuming you have them on disk :
lcPhotoPath = _samples+'\data\graphics\'
Select last_name, first_name, title from employee into cursor crsEmp
Copy to myEmployee type xls
oExcel = createobject('Excel.Application')
With oExcel
.Workbooks.Open(sys(5)+curdir()+'myEmployee.xls')
With .ActiveWorkbook.Activesheet
.Cells(1,4).Value = 'Photo'
Scan
lcPhoto = lcPhotoPath+left(last_name,4)+left(first_name,4)+'.GIF'
If file(lcPhoto)
.Range('D'+ltrim(str(recno()+1))).Select
.Pictures.Insert(lcPhoto)
Endif
Endscan
lnMaxWidth = 0
lnRatio = fontmetric(19,'Arial',11)/fontmetric(6,'Arial',11)/72
For each oShape in .Shapes
oShape.LockAspectRatio = .T.
oShape.Height = 72
lnMaxWidth = max(lnMaxWidth,oShape.Width)
Endfor
.Range('A2:D'+ltrim(str(reccount()+1))).RowHeight = 72
.Range('D:D').ColumnWidth = lnMaxWidth*lnRatio
.Columns('A:C').VerticalAlignment = -4108
Endwith
.Visible = .t.
Endwith
Cetin