Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi!
I'm trying to store some pictures on a spreadsheet into a BLOB column in an Oracle table. My strategy so far is as follows: 1. Copy the picture to a chart 2. Export the chart to a GIF file 3. Insert a row into the Oracle table with some keys (from the spreadsheet, offset from the topleftcell of the picture), and an empty BLOB. 4. Open the GIF file, read it (probably 4k chunks at a time) and update the BLOB in the row just inserted by appending the chunk to the BLOB, until EOF on the GIF file. I've got steps 1, 2 and 3 working, and have a stored procedure that takes key values and RAW input and updates the row by appending the RAW to the BLOB. How do I open and read the GIF file, in order to send RAW chunks of it to my SP? Is there a better way to accomplish this task, taking pictures from the spreadsheet and storing them in a database? Thanks in advance for any help or advice, elmo |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you need details within the .gif file, consider an OCR program to pull the
details out -- Gary's Student "elmo cambo" wrote: Hi! I'm trying to store some pictures on a spreadsheet into a BLOB column in an Oracle table. My strategy so far is as follows: 1. Copy the picture to a chart 2. Export the chart to a GIF file 3. Insert a row into the Oracle table with some keys (from the spreadsheet, offset from the topleftcell of the picture), and an empty BLOB. 4. Open the GIF file, read it (probably 4k chunks at a time) and update the BLOB in the row just inserted by appending the chunk to the BLOB, until EOF on the GIF file. I've got steps 1, 2 and 3 working, and have a stored procedure that takes key values and RAW input and updates the row by appending the RAW to the BLOB. How do I open and read the GIF file, in order to send RAW chunks of it to my SP? Is there a better way to accomplish this task, taking pictures from the spreadsheet and storing them in a database? Thanks in advance for any help or advice, elmo |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Depending on how you're connecting to Oracle my function below may be of
use. I found something like this on MSDN but it didn't work at all for some reason so I've changed it all around and it now works fine for me using ADO and an Access database This function updates the first row in a recordset with the passed file. The recordset should contain the primary key of the record as well as the BLOB field otherwise you get a "missing key" error. Private Const BlockSize = 32000 Function fcnLoadBlobIntoDatabase(SourceFile As String, _ r As Recordset, sField As String) As Boolean Dim NumBlocks As Integer, F As Integer, i As Integer Dim FileLength As Long, LeftOver As Long Dim FileData() As Byte On Error GoTo Err_ReadBLOB 'open the source file for access F = FreeFile Open SourceFile For Binary Access Read As F ' Get the length of the file. FileLength = LOF(F) If FileLength = 0 Then Exit Function ' Calculate the number of blocks to read and leftover bytes. LeftOver = FileLength Mod BlockSize NumBlocks = (FileLength - LeftOver) \ BlockSize 'Now load read the file in blocks and load into FileData Do While i <= NumBlocks 'size FileData as per blocksize of the same size 'as the remaining data If i < NumBlocks Then ReDim FileData(BlockSize - 1) Else ReDim FileData(LeftOver - 1) End If 'Read the data from the file into FileData Get F, , FileData 'append to our BLOB field r(sField).AppendChunk (FileData) 'increment our block counter i = i + 1 Loop ' Update the record - we're done r.Update fcnLoadBlobIntoDatabase = True Err_ReadBLOB: r.close On Error Resume Next Close F End Function elmo cambo wrote: Hi! I'm trying to store some pictures on a spreadsheet into a BLOB column in an Oracle table. My strategy so far is as follows: 1. Copy the picture to a chart 2. Export the chart to a GIF file 3. Insert a row into the Oracle table with some keys (from the spreadsheet, offset from the topleftcell of the picture), and an empty BLOB. 4. Open the GIF file, read it (probably 4k chunks at a time) and update the BLOB in the row just inserted by appending the chunk to the BLOB, until EOF on the GIF file. I've got steps 1, 2 and 3 working, and have a stored procedure that takes key values and RAW input and updates the row by appending the RAW to the BLOB. How do I open and read the GIF file, in order to send RAW chunks of it to my SP? Is there a better way to accomplish this task, taking pictures from the spreadsheet and storing them in a database? Thanks in advance for any help or advice, elmo |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Gman - perfect! Thank you very much. With just a little effort, I can make
this work. I didn't know about Open file For Binary Access Read, Freefile, AppendChunk, &c., which is exactly what I needed to know. Thanks again! |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You're welcome - I'm glad someone else can use it.
elmo cambo wrote: Gman - perfect! Thank you very much. With just a little effort, I can make this work. I didn't know about Open file For Binary Access Read, Freefile, AppendChunk, &c., which is exactly what I needed to know. Thanks again! |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do you save an excel file to be read as IBM-type text file ? | Excel Worksheet Functions | |||
I have a read only xl file, I need it to be read and write | Excel Discussion (Misc queries) | |||
XCEL FILE REC'D AS READ ONLY -- HOW TO NOT BE "READ ONLY" | Excel Discussion (Misc queries) | |||
How can a file be converted from Read-Only to Read/Write | Excel Discussion (Misc queries) | |||
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. | Charts and Charting in Excel |