Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How can I read a gif file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default How can I read a gif file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How can I read a gif file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How can I read a gif file?

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default How can I read a gif file?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you save an excel file to be read as IBM-type text file ? Dee Franklin Excel Worksheet Functions 2 October 10th 06 02:46 AM
I have a read only xl file, I need it to be read and write drama queen Excel Discussion (Misc queries) 3 July 1st 06 12:25 AM
XCEL FILE REC'D AS READ ONLY -- HOW TO NOT BE "READ ONLY" billybob Excel Discussion (Misc queries) 1 February 13th 06 03:14 AM
How can a file be converted from Read-Only to Read/Write Jim in Apopka Excel Discussion (Misc queries) 2 November 19th 05 04:59 PM
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. Tim Marsden Charts and Charting in Excel 2 October 15th 05 02:10 PM


All times are GMT +1. The time now is 02:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"