Focal Point
[SOLVED] Formatting bits of text in output formats

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/8267043616

February 06, 2012, 01:33 PM
mpbMDE
[SOLVED] Formatting bits of text in output formats
If I code 'Miscellaneous Cooperative Districts (type 52,53)' (in formatting markup tags) with the "" ('i' inside of carets) and '''' ('/i' inside of carets), then I see (type 52,53) in Italic for my HTML report. Can anyone tell me how to code EXL2K and PDF output that way: So that bits of the heading are formatted differently?

This message has been edited. Last edited by: Kerry,


WebFOCUS 8.1.05 Windows 7, all output
February 06, 2012, 03:07 PM
Waz
If you post any code within the
</>
code tags we will be able to see them.

Can you post an example working of one of the sample files like CAR.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

February 06, 2012, 03:35 PM
mpbMDE
Let me take some time and put that example together. Thanks!!


WebFOCUS 8.1.05 Windows 7, all output
February 06, 2012, 03:48 PM
njsden
Where exactly are you putting that? in a HEADING, SUBHEAD, SUBFOOT section perhaps?

Why not using the default functionality in WebFOCUS to style your content in italics?

TABLE FILE CAR
PRINT CAR AND MODEL
BY COUNTRY
HEADING
"List of cars (<+0>by Country<+0>)"
ON TABLE PCHOLD FORMAT EXL2K
ON TABLE SET STYLE *
TYPE=HEADING, OBJECT=TEXT, ITEM=2, STYLE=ITALIC, $
END



That worked seamlessly in HTML, PDF and EXL2K without resorting to specific HTML markup tags. It makes it more "portable" across output formats that support styling.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 06, 2012, 03:57 PM
mpbMDE
Using STYLESHEET to format the text doesn't work for me. I want to format different words of the text in different fonts/sizes/italic. It is all one field. STYLESHEET will format the entire field in a single format. At least that's been my experience.

The focexec actually uses the MacGyver technique to set the text value for 98 different values. (Yep - lots of typing) These values are what I want to format in bits and pieces.
Marilyn


WebFOCUS 8.1.05 Windows 7, all output
February 06, 2012, 03:57 PM
Waz
njsden, he's using markup tags, I think we need to see the code.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

February 06, 2012, 04:04 PM
mpbMDE
OK. Someone just dropped a 'hot iron' on my desk. So I mak not get back for a day or two. I WILL prepare some CAR code.


WebFOCUS 8.1.05 Windows 7, all output
February 06, 2012, 04:06 PM
njsden
quote:
It is all one field


Oh, you had missed that small but important piece of information.

I think there is a MARKUP=ON setting in the stylesheet section that applies when using PDF (I have not used that myself but a search in the forum might give you some samples).

I am not so sure that Excel will allow mixed formatting in one single cell but only testing will tell.

I'll do as Waz says and will wait for the code to show up.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 06, 2012, 04:22 PM
Waz
njsden, I think we were both right and wrong.

If I'm right Marilyn has a field that has HMTL tags in it. They work in HTML but not PDF or Excel.

This works in PDF and HTML, but doesn't in EXL2K.

DEFINE FILE CAR
HEAD_TEXT/A100 = 'Miscellaneous Cooperative Districts <FONT SIZE=8><I>(type 52,53)</I></FONT>' ;
END

TABLE FILE CAR
HEADING
"<HEAD_TEXT"
PRINT COUNTRY
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
 TYPE=HEADING, MARKUP=ON, $
ENDSTYLE
END



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

February 07, 2012, 12:13 PM
mpbMDE
You are 'right on'! Thanks!

This code:
 DEFINE FILE CAR
HEAD_TEXT/A100 = '<FONT SIZE=12>Miscellaneous Cooperative Districts <FONT><FONT SIZE=-2><I>(type 52,53)</I></FONT>' ;
END

TABLE FILE CAR
HEADING
"<HEAD_TEXT"
PRINT COUNTRY
ON TABLE PCHOLD FORMAT HTML
ON TABLE SET STYLE *
 TYPE=HEADING, 
MARKUP=ON, 
 $
ENDSTYLE
END
 

works works for italics in PDF and HTML, with MARKUP=ON. I can't seem to change the font size of the first part of the heading in PDF.
I'll explore the "MARKUP=ON".


WebFOCUS 8.1.05 Windows 7, all output
February 07, 2012, 12:50 PM
njsden
You could use this old trick to "make it work" in Excel:

DEFINE FILE CAR
HEAD_TEXT/A100 = 'Miscellaneous Cooperative Districts <FONT SIZE=8>[i](type 52,53)[/i]</FONT>' ;
END

TABLE FILE CAR
HEADING
"<HEAD_TEXT"
PRINT COUNTRY
ON TABLE HOLD AS HRESULT FORMAT HTMTABLE
ON TABLE SET STYLE *
 TYPE=HEADING, MARKUP=ON, $
ENDSTYLE
END
-RUN

SET HTMLFORMTYPE=XLS
-HTMLFORM BEGIN
<html>
   <head><title>Formatting mark-up!</title></head>
   <body>!IBI.FIL.HRESULT;</body>
</html
-HTMLFORM END



You will technically be creating an HTML document but altering it's MIME spec to open it with Excel which works just fine ... I just hope you're not using EXL2K FORMULA or PIVOT tables in your WebFOCUS output.

This message has been edited. Last edited by: njsden,



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 07, 2012, 01:05 PM
njsden
Marilyn, if your requirement is not GUI-bound the code below will take care of adjusting the output depending on the chosen format (HTML, PDF or EXL2K). Well, it should technically work with any "styled" format but the markup tags won't be interpreted as you need.

-DEFAULT &WFFMT = 'EXL2K';

-SET &PCHOLD = IF &WFFMT EQ 'EXL2K' THEN 'HOLD AS HRESULT FORMAT HTMTABLE'
-              ELSE 'PCHOLD FORMAT ' | &WFFMT;

DEFINE FILE CAR
HEAD_TEXT/A100 = 'Miscellaneous Cooperative Districts <FONT SIZE=8><I>(type 52,53)</I></FONT>' ;
END

TABLE FILE CAR
HEADING
"<HEAD_TEXT"
PRINT COUNTRY
ON TABLE &PCHOLD
ON TABLE SET STYLE *
 TYPE=HEADING, MARKUP=ON, $
ENDSTYLE
END
-RUN

-IF &WFFMT NE 'EXL2K' THEN GOTO :END;

SET HTMLFORMTYPE=XLS
-HTMLFORM BEGIN
<html>
   <head><title>Formatting mark-up!</title></head>
   <body>!IBI.FIL.HRESULT;</body>
</html
-HTMLFORM END

-:END




Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
February 08, 2012, 02:47 PM
mpbMDE
YOHOO! I have found a way for the same text formatting to work in HTML, PDF, and EXL2K! And it's all WebFOCUS code.
(Thanks for the MARKUP tip. It worked!) It has no effect of EXL2K or HTML, only PDF.
Then I discovered that the first character within the 'text' has to be a formatting character
<
in order to format text in EXL2K. So I have done that 2 different ways. (See NEW_FLD_TEXT and NEW2_FLD_TEXT.) The result is that the first character of the text is a 'blank' character, but that was ok for me.
Consider this:
-SET &TABLE_OUTPUT = 'PCHOLD FORMAT PDF';
-SET &X = IF &TABLE_OUTPUT EQ 'PCHOLD FORMAT HTML' THEN '' ELSE '<+0>';
DEFINE FILE CAR
HEAD_TEXT/A125 = '<font size=10>Miscellaneous Cooperative Districts</font> <font size=-2>[i](some text)[/i]</font>' ;
FLD_TEXT/A100 = IF CAR EQ 'TRIUMPH' THEN '<font size=+2><i>(any text,<font size=-2>smaller text)</i>' ELSE CAR ;
NEW_FLD_TEXT/A100 = IF CAR EQ 'TRIUMPH' THEN CAR ELSE '&X' | CAR | '<font size=+2><i>(any text,<font size=-2>SMALLER TEXT</i></font>' ;
NEW2_FLD_TEXT/A100 = IF CAR EQ 'TRIUMPH' THEN CAR ELSE '<i></i>' | CAR | '<font size=+2><i>(any text,<font size=-2>SMALLER TEXT</i></font>' ;
END
-*
TABLE FILE CAR
HEADING
"<HEAD_TEXT"
PRINT
CAR   AS '<b>Car</b>,<i>Name</i>'
MODEL AS '<i><u>M</u>odel</i>'
FLD_TEXT NEW_FLD_TEXT NEW2_FLD_TEXT
BY COUNTRY
ON TABLE &TABLE_OUTPUT
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     UNITS=IN,
     LEFTMARGIN=0.50000,
     RIGHTMARGIN=0.50000,
     TOPMARGIN=0.500000,
     BOTTOMMARGIN=0.500000,
     SQUEEZE=ON,
     ORIENTATION=LANDSCAPE,
     JUSTIFY=LEFT,
     SUMMARY='Text Format Report',
     TITLETEXT='Text Format Report',
$
TYPE=REPORT,
     GRID=OFF,
     FONT='ARIAL',
     SIZE=10,
     COLOR='BLACK',
     STYLE=NORMAL,
     MARKUP=OFF,

$
TYPE=REPORT, FONT=ARIAL, SIZE=10, MARKUP=ON, $
-*
TYPE=HEADING,MARKUP=ON, $
-*
TYPE=DATA, COLUMN=FLD_TEXT, JUSTIFY=LEFT, MARKUP=ON, $
TYPE=DATA, COLUMN=NEW_FLD_TEXT, JUSTIFY=LEFT, MARKUP=ON, $
TYPE=DATA, COLUMN=NEW2_FLD_TEXT, JUSTIFY=LEFT, MARKUP=ON, $
-*
ENDSTYLE
END  


I do have a question, though: Why does the 'NEW_FLD_TEXT' move way over into the 'FLD_TEXT' column? (only in PDF)

Thanks for you help and ideas!!

This message has been edited. Last edited by: mpbMDE,


WebFOCUS 8.1.05 Windows 7, all output