![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: RichText to MS-Word Topic Summary: Created On: 12-Nov-2003 21:50 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: It's true that there is a lot of extra junk in Microsoft's RTF files, but for your purposes it might be enough just to wrap your rtf with {\rtf1 .... }, e.g. {\rtf1{\strike The}{\ul the} big {\strike red}{\ul blue} fox{\ul }{\ul is}{\ul }{\ul here}} This works for me (opening in Wordpad). Judith Underwood | |
![]() |
|
I can generate text "reports" such that I can open them with MS-Word. I can also generate RichText reports such that I can set them to an attribute (obj.NameAttr = richText(Report)) or display them in a column (displayRich(Report)).
Given a RichText Report, doesn anybody know how I can export it such that it reads as rich text in MS-Word. Specifically, if i have a Bolded word in the report, can I make MS-Word bold it? I definately want to avoid the OLE export approach (oleMethod, etc) and prefer simply to put the rich text in a file and open the file in MS-Word. - Louie |
|
![]() |
|
![]() |
|
Not sure if this answers your question, but you can write the richText to a file with a ".rtf" extension and word will read it, as long as you remove the escape characters first.
So replace "\\" with "\". replace "\{" with "{" replace "\}" with "}" replace "\*" with "*" then write to the file. the following text is the output from string s = richText (current Object)."Object Text" print s \{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang1033\{\\fonttbl\{\\f0\\fnil\\fprq1\\fcharset0 Times New Roman;\}\{\\f1\\fnil\\fcharset2 Symbol;\}\} \{\\colortbl ;\\red0\\green0\\blue0;\} \\viewkind4\\uc1\\pard\\cf1\\i\\f0\\fs20 this is italic\\i0 \\par \\b this is bold\\b0 \\par \\strike this is strikethrough\\strike0 \\par \\ul this is underlined\\ulnone gfrerewte.\\par \\b\\i this is bold and italic\\b0\\i0 \\par \\pard\{\\pntext\\f1\\'B7\\tab\}\{\\*\\pn\\pnlvlblt\\pnf1\\pnindent0\{\\pntxtb\\'B7\}\}\\li360 fhfgh\\par \{\\pntext\\f1\\'B7\\tab\}sfghsfg\\par \{\\pntext\\f1\\'B7\\tab\}hsfghsfg\\par \{\\pntext\\f1\\'B7\\tab\}sfgh\\par \} the following has had the escape characters removed and is recognised by MS Word as RTF {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fprq1\fcharset0 Times New Roman;}{\f1\fnil\fcharset2 Symbol;}} {\colortbl ;\red0\green0\blue0;} \viewkind4\uc1\pard\cf1\i\f0\fs20 this is italic\i0 \par \b this is bold\b0 \par \strike this is strikethrough\strike0 \par \ul this is underlined\ulnone gfrerewte.\par \b\i this is bold and italic\b0\i0 \par \pard{\pntext\f1\'B7\tab}{*\pn\pnlvlblt\pnf1\pnindent0{\pntxtb\'B7}}\li360 fhfgh\par {\pntext\f1\'B7\tab}sfghsfg\par {\pntext\f1\'B7\tab}hsfghsfg\par {\pntext\f1\'B7\tab}sfgh\par } ------------------------- Tony Goodman http://www.smartdxl.com |
|
![]() |
|
![]() |
|
If you have a module with lots of these things, try the rtf exporter in table mode, with the report column in your view. It looks like the source is readable so if you want to create your own rtf you could start from that. Word sometimes does unpredicable things if you try to just concatenate the "{\rtf1 ..... }" strings.
Judith Underwood Edited: 13-Nov-2003 at 17:08 by Judith Underwood |
|
![]() |
|
![]() |
|
Sorry, but I've been side tracked. The RichText I've actually got doesn't look like your example. For those who are interested, I'm retrieving the raw text from a couple of attributes, calling function deltaText found in Telelogic's 'delta.inc', and displaying the results.
string s1 = "The big red fox" string s2 = "the big blue fox is here" string OutString = deltaText(s1, s2, 8, 4) print OutString. After applying your changes, what I actually end up with is RichText that looks like this: {\strike The}{\ul the} big {\strike red}{\ul blue} fox{\ul }{\ul is}{\ul }{\ul here} If you paste that into a Text attribute, it looks good. If you paste that into an *.rtf file, MS-Word thinks its just text and it looks the same. I want to manipulate the above so it looks good in MS-Word. - Louie Edited: 21-Nov-2003 at 20:09 by Louie Landale |
|
![]() |
|
![]() |
|
I think Microsoft puts a lot of extra stuff into their rtf files. You might be better off opening Word as a COM object and adding the info that way.
Alec |
|
![]() |
|
![]() |
|
It's true that there is a lot of extra junk in Microsoft's RTF files, but for your purposes it might be enough just to wrap your rtf with
{\rtf1 .... }, e.g. {\rtf1{\strike The}{\ul the} big {\strike red}{\ul blue} fox{\ul }{\ul is}{\ul }{\ul here}} This works for me (opening in Wordpad). Judith Underwood |
|
![]() |
|
![]() |
|
This seemed to work, as follows: any end-of-line markers (CRs) need to be "{\\par}". Tabs separating future MS-Word table cells can be normal tabs "\t". Once you build the entire text file, append "{\\rtf1 " to the front and "}" to the end. Write it to a "*.rtf" file. Open it with MS-Word.
Thanks to Goodman and Underwood. - Louie |
|
![]() |
Telelogic DOORS
» DXL Exchange
»
RichText to MS-Word
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.