PHP Save Excel as Word

Source: Internet
Author: User

Really feel this is like a series, just finished save as HTML, and made a save as word.

Here's how it works:
In fact, the principle is not difficult, after testing, fwrite write HTML code, as long as the CSS style inline style written, the last saved as Word can display the corresponding style content (about inline, outreach, embedded style definition, please self-search). For example, the HTML code reads:

<div style= ' color:red;font-weight:bold; ' ></div>

Then you can see the red bold text in the generated word. However, if the div is just written in class= ' className ' form, Word will not parse it.

Based on this idea, the CSS style that was originally written in the head is appended directly to the table, and the scientific name, called an inline style sheet (internal style sheet), is changed to inline style to save the style as word.
My initial method is to copy the HTML class Phpexcel, modified as the word class, but in the process of modification, found the Setuseinlinecss method, from the method name can be seen, this is set whether the use of inline style, sad to urge, I had already changed half the time. Only to find that the original add this line of code, this shows, read through the code is how important, fortunately the original author of the code written very good, or else only headache to read ... Seriously suspected that the original author was also to save as word, so deliberately added such a feature ... (⊙﹏⊙) b

However, there is another benefit, when the source code for the PDF saved as HTML, but also added the TAB function, which will be generated for multiple sheet navigation... It is an egg, it may be used later.

PHP Save Excel as Word

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.