Can we save ckeditor data into doc file

前端 未结 1 655
Happy的楠姐
Happy的楠姐 2020-12-06 21:49

in my site the admin edits some data which i need to save to a doc file. so i implemented this using ckeditor. It works fine but when i try to open this file it says \"word

1条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 22:04

    There is no problem with your code. The problem is that the file you are creating is a regular text file with the doc extension, in other words not a real Word file. If you don't have to write a doc file, just keep it as a plain .txt and that will solve the problem.

    Now if your project specs require you to have that file as a doc, you can do the following:

    1. Use the "HTML" approach(no COM required) Take a look at Sergey Kornilov's post: Create Word Document using PHP in Linux

      There is also a similar question here: Reading/Writing a MS Word file in PHP

    2. Use a COM Object - you will have to go that route if you need an elaborate word file

    This is from my experience. Let's hope somebody will come up with a better and more efficient solution.

    Good Luck!

    UPDATE: I automatically assumed you are working in a Win environment. In this case COM will do, if you need it to work on a Linux machine, your alternative is OpenOffice

    This is a decent article on COM and stuff: http://www.webcheatsheet.com/php/create_word_excel_csv_files_with_php.php#wordcom

    For OpenOffice just look at their API - http://api.openoffice.org/ Take a look at their forum, I am sure they have examples with PHP.

    My personal advice is to play with those, but work on a final solution after a day or two, if you have the time. Writing Word files is certainly not my forte, so there could possibly be another way of handling this.

    Good luck!

    UPDATE

    
    
    
    

    England would be keen to finish the summer on a high note by also remaining unbeaten in the upcoming ODI series against world champions India, said Test skipper Andrew Strauss after handing out the visitors a 4-0 whitewash.

    0 讨论(0)
提交回复
热议问题