I am trying to develop a excel spreadsheet that mirrors a set of reports. In a couple of the reports a JPG file stored in a General field in printed on the report. I need to know the method to allow me to copy the JPG file to a cell in the excel spreadsheet.
I didn't find that of much help but have gotten the code to work up to a point. I can now create a JPG file from the FoxPro General field. The problem now is getting Excel to accept the JPG file.
Here is the code that I have written with sigfile the General Field in table UserInfo1. This is a 1 record table.
COPY TO tempsig FIELDS userinfo1.sigfile NEXT 1
*** execute the following code, assuming the file name for the output JPG image is "TestSig.JPG":
*** Open two files, "UserInfo1.fpt" contains the physical JPG data.
*** and Create a file handle for the output file "TestSig.JPG"
handlein = FOPEN("TempSig.fpt"
handleout = FCREATE("testsig.jpg"
*** To determine the length of the Input file "TempSig.fpt"
gnEnd = FSEEK(handlein, 0, 2)
gnTop = FSEEK(handlein, 0)
*** Store the whole file into a string "str1"
str1 = FREAD(handlein, gnEnd)
*** Offset 599 bytes from Str1 and save it to "str2"
str2 = RIGHT(str1,LEN(str1)-599)
*** Write "Str2" into the JPG file "TestSig.JPG"
n = FWRITE(handleout,str2)
*** Close both opened files
=FCLOSE(handlein)
=FCLOSE(handleout)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.