473,394 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

textarea fields --> export to ms word --> word is stretch

Hi,

I have fields from textareas.

With a click of a button, php is able to grab these fields and by using
header(), convert the output to Ms Word doc.

But the outcome of the word doc doesn't wrap the text in textarea.

the result is one very veyr long string of text which stretch MS word all
the way

how to over come that?

I've tried different wrap attributes.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Mar 2 '07 #1
6 4594

"Eric Layman" <namyalcire[at no spam]gmail.comwrote in message
news:11*************@sp6iad.superfeed.net...
| Hi,
|
| I have fields from textareas.
|
| With a click of a button, php is able to grab these fields and by using
| header(), convert the output to Ms Word doc.
|
| But the outcome of the word doc doesn't wrap the text in textarea.
|
| the result is one very veyr long string of text which stretch MS word all
| the way
|
| how to over come that?
|
| I've tried different wrap attributes.

hard to say without looking at the code you're using.

are you on a windows server? are you creating a com ms word doc object and
putting the text in that way? or, are you creating a standard text file and
calling it word (i.e. someDoc.doc or setting the header for the browser as
an ms word doc)?

if on windows, i'd go the com route and remove any soft-returns that may be
in the text. then, i'd use word's om to format the boundries, color, font,
etc. of the text as it should appear in word. what is word's om? the easiest
way to get what you need is to open word, record a macro, type and format
some text the way you want it to look as if it were really your output, stop
recording your macro. from there, just edit the macro. you will see the
source code and see all the methods/properties you will need to know and
work with. problem solved.

if not on windows, i'd get a good conversion tool, and even think about
using xml/xslt as an abstraction layer. that combination will allow you not
only to convert to word but to pdf and others as well.

anyway, hth.
Mar 2 '07 #2
Eric Layman wrote:
With a click of a button, php is able to grab these fields and by using
header(), convert the output to Ms Word doc.
The PHP header() function does no such thing -- it simply sends an HTTP
header. You might be able to use an HTTP header to convince a browser to
open a plain text file in Word, but the file is not really a Word file.

Similarly, I'd guess you could use the same trick to send an HTML file to
Word instead of sending a plain text file. So just add a few HTML tags
into your output and Word's heuristics ought to auto-detect that it's
HTML, and do line wrapping.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Mar 2 '07 #3

"Steve" <no****@example.comwrote in message
news:CO*************@newsfe06.lga...
>
"Eric Layman" <namyalcire[at no spam]gmail.comwrote in message
news:11*************@sp6iad.superfeed.net...
| Hi,
|
| I have fields from textareas.
|
| With a click of a button, php is able to grab these fields and by using
| header(), convert the output to Ms Word doc.
|
| But the outcome of the word doc doesn't wrap the text in textarea.
|
| the result is one very veyr long string of text which stretch MS word
all
| the way
|
| how to over come that?
|
| I've tried different wrap attributes.

hard to say without looking at the code you're using.

are you on a windows server? are you creating a com ms word doc object and
putting the text in that way? or, are you creating a standard text file
and
calling it word (i.e. someDoc.doc or setting the header for the browser as
an ms word doc)?

if on windows, i'd go the com route and remove any soft-returns that may
be
in the text. then, i'd use word's om to format the boundries, color, font,
etc. of the text as it should appear in word. what is word's om? the
easiest
way to get what you need is to open word, record a macro, type and format
some text the way you want it to look as if it were really your output,
stop
recording your macro. from there, just edit the macro. you will see the
source code and see all the methods/properties you will need to know and
work with. problem solved.

if not on windows, i'd get a good conversion tool, and even think about
using xml/xslt as an abstraction layer. that combination will allow you
not
only to convert to word but to pdf and others as well.

anyway, hth.

Thanks Steve.

Let me explain further:

I have a form which has textareas and allows user inputs which saves to
mysql database.

The administrator is able to view these textarea inputs by clicking a
button. This button will pull out these information and generate a word
document.

Problem is that when word documents are generated, the text in these word
documents are stretchhhhhhhhhhhhhhhhhhhhhhhhhhhhhh till the very extreme
right end.

These texts in the word doc are the data that is keyed in by end users via
the textarea.

It seems that the generated word doc is not able to capture the linebreaks
within the textarea.

Pls advise.

Thanks

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Mar 3 '07 #4
On 3 Mar, 16:25, "Eric Layman" <namyalcire[at no spam]gmail.com>
wrote:
"Steve" <no....@example.comwrote in message

news:CO*************@newsfe06.lga...


"Eric Layman" <namyalcire[at no spam]gmail.comwrote in message
news:11*************@sp6iad.superfeed.net...
| Hi,
|
| I have fields from textareas.
|
| With a click of a button, php is able to grab these fields and by using
| header(), convert the output to Ms Word doc.
|
| But the outcome of the word doc doesn't wrap the text in textarea.
|
| the result is one very veyr long string of text which stretch MS word
all
| the way
|
| how to over come that?
|
| I've tried different wrap attributes.
hard to say without looking at the code you're using.
are you on a windows server? are you creating a com ms word doc object and
putting the text in that way? or, are you creating a standard text file
and
calling it word (i.e. someDoc.doc or setting the header for the browser as
an ms word doc)?
if on windows, i'd go the com route and remove any soft-returns that may
be
in the text. then, i'd use word's om to format the boundries, color, font,
etc. of the text as it should appear in word. what is word's om? the
easiest
way to get what you need is to open word, record a macro, type and format
some text the way you want it to look as if it were really your output,
stop
recording your macro. from there, just edit the macro. you will see the
source code and see all the methods/properties you will need to know and
work with. problem solved.
if not on windows, i'd get a good conversion tool, and even think about
using xml/xslt as an abstraction layer. that combination will allow you
not
only to convert to word but to pdf and others as well.
anyway, hth.

Thanks Steve.

Let me explain further:

I have a form which has textareas and allows user inputs which saves to
mysql database.

The administrator is able to view these textarea inputs by clicking a
button. This button will pull out these information and generate a word
document.

Problem is that when word documents are generated, the text in these word
documents are stretchhhhhhhhhhhhhhhhhhhhhhhhhhhhhh till the very extreme
right end.

These texts in the word doc are the data that is keyed in by end users via
the textarea.

It seems that the generated word doc is not able to capture the linebreaks
within the textarea.

Pls advise.

Thanks

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
you can simply exchange the \n style line breaks from the textarea to
\r style line breaks or \r\n style.

However to immediately create word docs with absolutely minimal
memory, and no need to start up a COM instance of word, just create a
word doc and style it as you wish the admin to see, then put some text
in the place where the textarea text will be. Put something easy to
spot like ************_______********
then save as RTF, open in text edito and swap the
************______******** for {$TEXT}
then start the whole page off using
<?php $rtf = <<<RTF
and end it with
RTF;

this then you save as rtfdoc.php
and now you just take the textarea as $TEXT and set the header content
type msword, and include rtfdoc.php and echo it
if you serve the stream gzipped it will come out much smaller than an
actual word doc.
the whole thing works immediately and of course is rendered in word
just the same as a doc.
It works on linux server too, and can be opened in all version of
word, openoffice wordpad whatever.

just a thought for the future

Mar 3 '07 #5

"shimmyshack" <ma********@gmail.comwrote in message
news:11**********************@31g2000cwt.googlegro ups.com...
| On 3 Mar, 16:25, "Eric Layman" <namyalcire[at no spam]gmail.com>
| wrote:
| "Steve" <no....@example.comwrote in message
| >
| news:CO*************@newsfe06.lga...
| >
| >
| >
| >
| >
| "Eric Layman" <namyalcire[at no spam]gmail.comwrote in message
| news:11*************@sp6iad.superfeed.net...
| | Hi,
| |
| | I have fields from textareas.
| |
| | With a click of a button, php is able to grab these fields and by
using
| | header(), convert the output to Ms Word doc.
| |
| | But the outcome of the word doc doesn't wrap the text in textarea.
| |
| | the result is one very veyr long string of text which stretch MS
word
| all
| | the way
| |
| | how to over come that?
| |
| | I've tried different wrap attributes.
| >
| hard to say without looking at the code you're using.
| >
| are you on a windows server? are you creating a com ms word doc object
and
| putting the text in that way? or, are you creating a standard text
file
| and
| calling it word (i.e. someDoc.doc or setting the header for the
browser as
| an ms word doc)?
| >
| if on windows, i'd go the com route and remove any soft-returns that
may
| be
| in the text. then, i'd use word's om to format the boundries, color,
font,
| etc. of the text as it should appear in word. what is word's om? the
| easiest
| way to get what you need is to open word, record a macro, type and
format
| some text the way you want it to look as if it were really your
output,
| stop
| recording your macro. from there, just edit the macro. you will see
the
| source code and see all the methods/properties you will need to know
and
| work with. problem solved.
| >
| if not on windows, i'd get a good conversion tool, and even think
about
| using xml/xslt as an abstraction layer. that combination will allow
you
| not
| only to convert to word but to pdf and others as well.
| >
| anyway, hth.
| >
| Thanks Steve.
| >
| Let me explain further:
| >
| I have a form which has textareas and allows user inputs which saves to
| mysql database.
| >
| The administrator is able to view these textarea inputs by clicking a
| button. This button will pull out these information and generate a word
| document.
| >
| Problem is that when word documents are generated, the text in these
word
| documents are stretchhhhhhhhhhhhhhhhhhhhhhhhhhhhhh till the very extreme
| right end.
| >
| These texts in the word doc are the data that is keyed in by end users
via
| the textarea.
| >
| It seems that the generated word doc is not able to capture the
linebreaks
| within the textarea.
| >
| Pls advise.
| >
| Thanks
| >
| Posted Via Usenet.com Premium Usenet Newsgroup Services
| ----------------------------------------------------------
| ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
| ----------------------------------------------------------
| http://www.usenet.com
|
| you can simply exchange the \n style line breaks from the textarea to
| \r style line breaks or \r\n style.
|
| However to immediately create word docs with absolutely minimal
| memory, and no need to start up a COM instance of word, just create a
| word doc and style it as you wish the admin to see, then put some text
| in the place where the textarea text will be. Put something easy to
| spot like ************_______********
| then save as RTF, open in text edito and swap the
| ************______******** for {$TEXT}
| then start the whole page off using
| <?php $rtf = <<<RTF
| and end it with
| RTF;
|
| this then you save as rtfdoc.php
| and now you just take the textarea as $TEXT and set the header content
| type msword, and include rtfdoc.php and echo it
| if you serve the stream gzipped it will come out much smaller than an
| actual word doc.
| the whole thing works immediately and of course is rendered in word
| just the same as a doc.
| It works on linux server too, and can be opened in all version of
| word, openoffice wordpad whatever.
|
| just a thought for the future
that's a great thought...i suppose a replace is much easier to do and not
platform dependent.
Mar 3 '07 #6
On 3 Mar, 03:20, "Steve" <no....@example.comwrote:
"shimmyshack" <matt.fa...@gmail.comwrote in message

news:11**********************@31g2000cwt.googlegro ups.com...
| On 3 Mar, 16:25, "Eric Layman" <namyalcire[at no spam]gmail.com>| wrote:

| "Steve" <no....@example.comwrote in message
| >
| >news:CO*************@newsfe06.lga...
| >
| >
| >
| >
| >
| "Eric Layman" <namyalcire[at no spam]gmail.comwrote in message
| news:11*************@sp6iad.superfeed.net...
| | Hi,
| |
| | I have fields from textareas.
| |
| | With a click of a button, php is able to grab these fields and by
using
| | header(), convert the output to Ms Word doc.
| |
| | But the outcome of the word doc doesn't wrap the text in textarea.
| |
| | the result is one very veyr long string of text which stretch MS
word
| all
| | the way
| |
| | how to over come that?
| |
| | I've tried different wrap attributes.
| >
| hard to say without looking at the code you're using.
| >
| are you on a windows server? are you creating a com ms word doc object
and
| putting the text in that way? or, are you creating a standard text
file
| and
| calling it word (i.e. someDoc.doc or setting the header for the
browser as
| an ms word doc)?
| >
| if on windows, i'd go the com route and remove any soft-returns that
may
| be
| in the text. then, i'd use word's om to format the boundries, color,
font,
| etc. of the text as it should appear in word. what is word's om? the
| easiest
| way to get what you need is to open word, record a macro, type and
format
| some text the way you want it to look as if it were really your
output,
| stop
| recording your macro. from there, just edit the macro. you will see
the
| source code and see all the methods/properties you will need to know
and
| work with. problem solved.
| >
| if not on windows, i'd get a good conversion tool, and even think
about
| using xml/xslt as an abstraction layer. that combination will allow
you
| not
| only to convert to word but to pdf and others as well.
| >
| anyway, hth.
| >
| Thanks Steve.
| >
| Let me explain further:
| >
| I have a form which has textareas and allows user inputs which saves to
| mysql database.
| >
| The administrator is able to view these textarea inputs by clicking a
| button. This button will pull out these information and generate a word
| document.
| >
| Problem is that when word documents are generated, the text in these
word
| documents are stretchhhhhhhhhhhhhhhhhhhhhhhhhhhhhh till the very extreme
| right end.
| >
| These texts in the word doc are the data that is keyed in by end users
via
| the textarea.
| >
| It seems that the generated word doc is not able to capture the
linebreaks
| within the textarea.
| >
| Pls advise.
| >
| Thanks
| >
| Posted Via Usenet.com Premium Usenet Newsgroup Services
| ----------------------------------------------------------
| ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
| ----------------------------------------------------------
| http://www.usenet.com
|
| you can simply exchange the \n style line breaks from the textarea to
| \r style line breaks or \r\n style.
|
| However to immediately create word docs with absolutely minimal
| memory, and no need to start up a COM instance of word, just create a
| word doc and style it as you wish the admin to see, then put some text
| in the place where the textarea text will be. Put something easy to
| spot like ************_______********
| then save as RTF, open in text edito and swap the
| ************______******** for {$TEXT}
| then start the whole page off using
| <?php $rtf = <<<RTF
| and end it with
| RTF;
|
| this then you save as rtfdoc.php
| and now you just take the textarea as $TEXT and set the header content
| type msword, and include rtfdoc.php and echo it
| if you serve the stream gzipped it will come out much smaller than an
| actual word doc.
| the whole thing works immediately and of course is rendered in word
| just the same as a doc.
| It works on linux server too, and can be opened in all version of
| word, openoffice wordpad whatever.
|
| just a thought for the future

that's a great thought...i suppose a replace is much easier to do and not
platform dependent.
yes, you can make really show stopping docs this way in 0.1secs! The
only thing that complicates this method is when you have a multipage
document, or start inserting hyperlinks - you have to know or be
prepared to stare at the raw RTF source for a bit to work out where
the page break is and what commands can be used to insert that link
(but RTF is an open format after M$ released it), looping round adding
content finishing off with "continued..." if it isn't quite the end of
the doc.
The real show stopper is embedded images, this is where using the
binary word format wins because the included image can be binary too,
in an RTF the image has to be base64 encoded which makes the byte
count for the image much bigger of course - rather annoying, gzipping
helps but it doesn't quite work, particularly for 1MB images - forget
that!
For those interested this method is the same for open office
documents, just make your OO doc, unzip the files to a directory, and
use the contents.xml as the strings you will replace an array of
output text into, then zip the whole thing up on the fly and serve as
an sxw, again it is super quick and platform independent.
I feel like I am advocating the use of a upsidedown underwater pencil,
but if you find yourself on unix with no access to office with a
server license...

Mar 3 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Markus Ernst | last post by:
Hi I wrote a function that "normalizes" strings for use in URLs in a UTF-8 encoded content administration application. After having removed the accents from latin characters I try to remove all...
4
by: Paolo | last post by:
Hello, I am trying to create a procedure to export my Access data to a word template. I would like to export data from two tables to a word file at the same time. My two tables are named CASES...
8
by: Frost | last post by:
Hi All, I am a newbie i have written a c program on unix for line by line comparison for two files now could some one help on how i could do word by word comparison in case both lines have the...
2
by: spidey12345 | last post by:
what i need this program to do is to read paragraphs like "st blah blh test ere se sit blha eere w" and then it will reformat to "st blah...
1
by: rogoflap | last post by:
I have some regular text I export to a word document. I build this in VBA in Access and want dump it into word. I can do this, but would like to know how I can turn on an off bolding or...
5
by: JWest46088 | last post by:
I can't figure out how to read a file word by word. I want to open the file and then read it one word at a time. For example, I'm looking for words that start with d. How would I scan each word of...
5
by: Stuudent | last post by:
Hi! Is there possibility to read char* table word by word in C (not C++)? I'm learning C by writing simple HTTP Server on BSD sockets (just for fun). And I want to read info from HTTP header...
9
by: George | last post by:
C with 2 sprained hands. I would nlike to emulate the t4 encoding scheme using the following graphic: * * * * * * ***** o O o o
0
by: Roopa Nagaral | last post by:
Hi, I am working on vb.net... i need to retrieve particular word from word document and display it on vb.net label or textbox... like in word documnet Name : xyz DOB: 13/02/1990 here i v to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.