delphi64-bitoffice-2010sqlfilestream

Which problems exist when using 32bit applications that handle Office 2010 64bit files?


I am testing one application that handles files (stored in SQL Server using FILESTREAM). It is a Delphi 32bit application.

Opening an XLS document stored in the database (originally saved with Office 2003) gives an error from Excel 2010 64bit. Is there some known compatibility issue of Office 2010 64bit with 32bit applications?

Error messages and workflow

When opening the file Excel gives one of the following error messages:

Opening a file on machine A with Office 2007 opens the file with no problems. Opening the same file on machine B with Office 2010 produces the error message. Opening again on machine A there is also an error message! In all these steps I am just reading from the database, not writing. So why does this can happen?

How do I open the documents?

  1. SELECT query to get 'DOCUMENT' varbinary(max) field for the specific ID_Document.
  2. Extract from database using TBlobField(sqlQuery.FieldByName('DOCUMENT')).SaveToFile(sDestinationPath + FileUniqueName + .zip');
  3. Copy file from one path to another using Windows.CopyFile
  4. Unzip file using TZipforge component
  5. Set attribute of unzipped file to ROM using FileSetReadOnly function.
  6. Open document using ShellExecute(0, 'open', PWideChar(FIleName), '', '', SW_SHOWNORMAL);

As you can see there is nothing that writes back to the database. Once the file is extracted from TBlobField it is even copied to another place before unzipping and opening it.

Possibly broken installation

Office has been reinstalled and now everything works, the problem of corruption was due to a conflict with an open Office installation that asked "do you want to fix the office installation?". Anyway the problem still remains, because I cannot understand what happened. How can I corrupt a file in the database if I extract it in a folder and open it from the folder without writing anything back to database?


Solution

  • Solved: it was a bug in my program. There was an error in the logic that persisted the document status and by mistake sometimes Is_File_Compressed was set to False, even if it is true.

    Thanks for the support.