Board index » delphi » Help saving VTS or XLS file to Blob

Help saving VTS or XLS file to Blob

Hi,

I've been unsuccessful getting an XLS or VTS (Formula One) file to a
blob field.  I've tried multiple ways .... Load the file with a
Filestream then into a Blobstream.... works fine for HTM files but not
XLS or VTS.  A binary file comparison reveals differences when I put the

file back.

Thanks in Advance,

 

Re:Help saving VTS or XLS file to Blob


Brett,

Here are my routines, they are from a component I wrote, so you'll have to
modifiy them some. Change fDatalink.Field to your dataset's field, etc.

Write:

    Set8087CW($133f);  { Disable all fpu exceptions }
      try
         Application.ProcessMessages;
         fBook.SaveWindowInfo;
         MyBlob := GlobalAlloc(GMEM_MOVEABLE, 2000);
         try
            fBook.WriteToBlob(MyBlob, 0);
            pBlob := globalLock(MyBlob);
            try
               BlobStream :=
                  TBlobStream.Create(TBlobField(fDataLink.Field), bmWrite);
               try
                  BlobStream.Write(pBlob^,GlobalSize(myBlob));
               finally
                  Blobstream.Free;
               end; {try/finally}
            finally
               globalUnlock(MyBlob);
            end; {try/finally}
            fBook.IF1Book_Modified := False;
         finally
            globalFree(myBlob);
         end; {try/finally}
      finally
       Set8087CW(Default8087CW);
     Application.ProcessMessages;
      end;

Read:

            BlobStream := TBlobStream.Create(TBlobField(fDataLink.Field),
bmRead);
            try
               if BlobStream.Size > 0 then
               begin
                  BlobSize := BlobStream.Size{ + 1};
                  MyBlob := GlobalAlloc(GMEM_MOVEABLE, BlobSize);
                  try
                     pBlob := globalLock(MyBlob);
                     try
                        BlobStream.Read(pBlob^, BlobSize);
                        fBook.ReadFromBlob(MyBlob, 0);
                     finally
                        globalUnlock(MyBlob);
                     end;
                  finally
                     globalFree(myBlob);
                  end;
               end
               else
               begin
              fBook.numSheets := 1;
              fBook.ClearRange(-1, -1, -1, -1, kClearAll);
               end;
            finally
               BlobStream.Free;
            end;

Quote
Brett McLean wrote:
> Hi,

> I've been unsuccessful getting an XLS or VTS (Formula One) file to a
> blob field.  I've tried multiple ways .... Load the file with a
> Filestream then into a Blobstream.... works fine for HTM files but not
> XLS or VTS.  A binary file comparison reveals differences when I put the

> file back.

> Thanks in Advance,

--
Ken Bailey
Falmouth Software Works Ltd.

Other Threads