A new question has been raised inside Foxite which is how we can extract and save images from within an excel workbook so I thought, how indeed?
We can do manually by clicking an image (or a group of images) then choosing copy, opening paint and pasting it over there. Man, that would be tiresome.
Or we can ensure the format to be of xlsx (2007 and 2010) then later renaming the extension from xlsx into zip, extracting that newly renamed zip file and digging into subfolder xl, then media to get all the jpeg and png images from within the worksheet file. Read this if you are confused: http://sandstorm36.blogspot.com.au/2012/02/why-appendimport-from-xlsx-fails.html
Another way which is much simpler because it does not require that manual renaming of xlsx to zip is this, saving the excel file into an HTML format and digging as well into the folder that holds images for the HTML. And this is the way I decided to go for this example. Here is the result:
And here are the codes:
Define Class Form1 As Form
Height = 390
Width = 500
AutoCenter = .T.
Caption = 'Extracting Images from an Excel'
Add Object grid1 As Grid With ;
GridLines = 0, ;
Height = 328, ;
Left = 10, ;
Top = 50, ;
Width = 150,;
GridLines = 0,;
DeleteMark = .F.,;
GridLineColor = Rgb(192,192,192),;
FontName = 'Tahoma',;
FontSize = 10,;
AllowCellSelection = .F.,;
RecordSource = 'junk'
Add Object Image1 As Image With;
top = 15, Left = 180, Width = 300, Height =300,;
Stretch = 2
Set Talk Off
Set Safety Off
#Define xlHtml 44
Local lcfile, lnloop, lcHTML
lcfile = Getfile('xlsx')
lcHTML = Addbs(Getenv("tmp"))+Sys(3)
Local loExcel As excel.Application
loExcel = Createobject("Excel.Application")
* Save into HTML format
Create Cursor junk (ImageName c(20), xImage M)
* get images
Set Default To (m.lcHTML)+'_files'
lnFound = Adir(laImages,'image*.*')
If m.lnFound > 0
For lnloop = 1 To m.lnFound
Insert Into junk Values ;
* PictureVal in my end is having problem when format is
* PNG,so we will not work directly with image values here
If Getwordnum(Alltrim(junk.ImageName),2,'.') = 'PNG'
lcfile = Getenv("TMP")+'\tempimage'
Thisform.Image1.Picture = m.lcfile
* Work directly with image values
Thisform.Image1.PictureVal = junk.xImage
Shown above is how we can use Picture and PictureVal properties for your comparison.