Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
martynlloyd
Contributor III

Use script to write HTML

Hi everyone,

I'm trying to produce an html snippet, using just scripting.  I am unable to use macros in this context.

So close, but not there; the output looks like this:

<HTML>,HTML
<head>,
<style>,
body {background-color:lightgrey},
h1   {color:blue},
p    {color:green},
</style>,
</head>,
<body>,
,2536
</body>,

How can I resolve the fact that I have two fields - the editor will not accept <HTML> as a field name...

here is the script

OrderMassTotal:
LOAD 
     KPIYear,
    
Sum(Volume) as [TotalRetailOrders]
Resident KPIFACTS
Where KPIID='S12' and KPIYear=2015
Group By KPIYear;

OrderHeadline:
Load * Inline [
<HTML>
<head>
<style>
  body {background-color:lightgrey}
  h1   {color:blue}
  p    {color:green}
</style>
</head>
<body>
]
;

Concatenate
Load
Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML
AutoGenerate(1)
;

Concatenate
Load * Inline [
<HTML>
</body>
]
;

STORE OrderHeadline into [$(vQVDPath)\KPIOrderRetailHeadline.html] (txt);

Best regards,

Marty.

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

Re: Use script to write HTML

Hi

You were nearly there. Just change this line:

Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML

It should read:

Peek('TotalRetailOrders', -1, 'OrderMassTotal') as [<HTML>]

Then it should work - it did when I tested it. This is what the output file contained (you will have a different value from the 500 below):

<HTML>

<head>

<style>

body {background-color:lightgrey}

h1   {color:blue}

p    {color:green}

</style>

</head>

<body>

500

</body>

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
3 Replies

Re: Use script to write HTML

Maybe this is helpful for you:

OrderHeadline:

Load *, rowno() as RowNo Inline [

HTML-Code

<HTML>

<head>

<style>

  body {background-color:lightgrey}

  h1   {color:blue}

  p    {color:green}

</style>

</head>

<body>

];

HTML:

NoConcatenate Load

    concat([HTML-Code], chr(10), RowNo) as [HTML-Code]

Resident OrderHeadline;

drop tables OrderHeadline;

- Marcus

MVP
MVP

Re: Use script to write HTML

Hi

You were nearly there. Just change this line:

Peek(TotalRetailOrders, -1, 'OrderMassTotal') as HTML

It should read:

Peek('TotalRetailOrders', -1, 'OrderMassTotal') as [<HTML>]

Then it should work - it did when I tested it. This is what the output file contained (you will have a different value from the 500 below):

<HTML>

<head>

<style>

body {background-color:lightgrey}

h1   {color:blue}

p    {color:green}

</style>

</head>

<body>

500

</body>

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
martynlloyd
Contributor III

Re: Use script to write HTML

Thanks Jonathan!

I should have seen that one.

M.

Community Browser