Categories > OpenTBS with DOCX >

MS Office Reporting Corrupt File

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Ben Collier
Date: 2011-12-22
Time: 13:56

MS Office Reporting Corrupt File

Hi,

Firstly, may I say that OpenTBS is a complete godsend. It's absolutely fantastic, thanks.

Secondly, I do have a slight problem. I've created a script which uses most of the code from the demo, minus some bits to do with file formats which I'm not interested in. When I download the file that is created, MS Word 2010 Express reports that it cannot open the file, as it is corrupt. However, when I choose to recover the file, it is presented perfectly, with all of the mergefields that I specified.

Is there something in particular that I am likely to be doing wrong, as the demo file downloads perfectly?
By: Skrol29
Date: 2011-12-23
Time: 18:09

Re: MS Office Reporting Corrupt File

Hi Ben,

Thank you very much for your appreciation :-:

> minus some bits to do with file formats which I'm not interested in

Can you give precisions ?

When the created file is corrupted, the classical problem is that your code is outputting some extra unexpected characters.
You can check by checking the very first binary bytes of the file. You can also check by using the debug mode.
By: Ben Collier
Date: 2011-12-28
Time: 13:51

Re: MS Office Reporting Corrupt File

Hi! Yes, looks as though that's the problem. The files that my code is generating include a carriage return at the beginning of the file. They did include some other echoed words. I've managed to remove the words, by removing the echo statements, but I can't seem to remove the carriage return and have no idea where it's coming from. Any ideas? There are no longer any echo statements in the php file which calls opentbs.
By: Ben Collier
Date: 2011-12-28
Time: 13:56

Re: MS Office Reporting Corrupt File

Sorry, scratch that, I opened and closed the PHP which inserted the character. Thanks for your help.

Excellent code, thank you very much indeed once again.