PHP Export method to generate word _php tips

Source: Internet
Author: User

The example in this article describes how the PHP export generates word. Share to everyone for your reference, specific as follows:

PHP Export Word

(1) First, preview the HTML page, sample the object, define the data to be exported
(2) Click on the download page, to the ID pass value (any value can be used only for judgment), if the ID has a value, output buffer file, save in Word format.
(3) Click on the download, (if it is a picture, when saving as word to use the absolute path, so that you can in the saved word normal display)
(4) Turn off the cache output

word_con.php preview of HTML files to export

<?php
if (@$_get[id]!= ')
{
 include (' word_fun.php ');
 $word =new Word ()///The Sample object
 $word->start ();//define the start of the data to be saved
}
include (' word_show.php ');
 if (@$_get[id]!= ')
 {
   $word->save (' Word_c.doc ');//define the end of the data to be saved and save the data to
 word
 (@$_get[ id]== ')
 {
 //hyperlink x is just to pass a value, confirm the download, no other actual Yi
 ?>
 <a href= "#" ><div onclick= " window.location.href= ' word_con.php?id=x ' > click to jump to download page </div></a>
 <?php
 }else{
 echo "<a href=\" word_c.doc\ "> Download </a>";
>

word_fun.php export word-related functions

<?php
class word
{
function start ()//define the beginning of the data to be saved
{
    ob_start ();//Start output buffer
    //Set format for word generation
    print '  
 

I hope this article will help you with the PHP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.