1
votes

I am testing one application that handles files (stored in sql server using filestream). It is a Delphi win32 application.

Opening a xls document stored in the db (originally saved with Office 2003) gives an error from Excel 2010 64bit.

Is there some known compatibility issues with Office 2010 64bit with win32 applications?

i am trying to get closer to the problem, but in the meantime I ask to have help.

*Additional notes:

When opening the file Excel gives the following error "Impossible to open the file FILE because of problems in contents"/"Impossible to open the file because some parts are missing or not valid".

Opening a file from machine A with office 2007 opens the file with no problems.

Opening the same file from machine B with office 2010 gives the problem.

Opening again from machine A it gives the problem! In all these steps I am just reading from db, not writing. So why this can happen?*

Extra update: how do I open the documents

These are the steps I use: 1. Select Query to get 'DOCUMENT' varbinary(max) field for Specific ID_Document.

  1. extract From Db using TBlobField(sqlQuery.FieldByName('DOCUMENT')).SaveToFile(sDestinationPath + FileUniqueName + .zip');

  2. Copy File from One Path to Another file using Windows.CopyFile

  3. Unzip file using TZipforge component

  4. Set attribute of unzipped file to readonly using FileSetReadOnly function.

  5. open document using

    ShellExecute(0, 'open', PWideChar(FIleName), '', '', SW_SHOWNORMAL);

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

FINAL NOTE:

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 DB if I extract in a folder and open it from the folder without psoting anything back to DB?

3
How to "open" your file? You should use ShellExecute() with proper parameters for that. - A.Bouchez
Yes I do, but before that I extract it from DB. see comment to The_Fox answer. - LaBracca
Can you save those files to disk on the x64 box and open them manually? - Todd Main
No i cannot, they are corrupted forever. - LaBracca

3 Answers

1
votes

Office 2010 64-bit should have no problems with files created with its 32-bit version. The files (.docx, .xls) are bitness independant.

I have some questions:

  1. How do you open your files?
  2. Can you show some code?
  3. Are you sure that you are only reading the file from the database?
  4. Do you give your files the right extension? Saving a .xls as .xlsx will cause problems when opening the file.
0
votes

Check if your SQL server database is corrupt. Check disk where database is for errors. Reinstall SQL server.

0
votes

FOUND!!!

Guess? Bug!

There was an error in the logic that persisted the document status and by mistake some times Is_File_Compressed where set to False, even if it is True.

Thanks for the support.