Solved

Powershell HTML Table

Posted on 2014-04-08
6
403 Views
Last Modified: 2014-04-16
Hi, I'm trying to creating table headers spanned across two rows.

The first header row - <tr><th>Heading1</th><th colspan="5">Heading2</th><th colspan="5">Heading3</th></tr>

The second header row <tr><th>&nbsp;</th><TH>H2Sub1</TH><TH>H2Sub2</TH><TH>H2Sub3</TH>..........

so then I can start to add rows of data underneath.

Thanks

Set-Content $rep "<HTML>"
Add-Content $rep "<Head>"

Add-Content $rep "<theader>"
Add-Content $rep "<tr>"
Add-Content $rep "<TH colspan="1">H1</TH>"
Add-Content $rep "<TH colspan="5">H2</TH>"
Add-Content $rep "<TH colspan="5">H3</TH>"
Add-Content $rep "</tr>"
Add-Content $rep "<tr>"
Add-Content $rep "<th>&nbsp;</th>"
Add-Content $rep "<TH>H2SubH1</TH>"
Add-Content $rep "<TH>H2SubH2</TH>"
Add-Content $rep "<TH>H2SubH3</TH>"
Add-Content $rep "<TH>H2SubH4</TH>"
Add-Content $rep "<TH>H2SubH5</TH>"
Add-Content $rep "<TH>H3SubH1</TH>"
Add-Content $rep "<TH>H3SubH2</TH>"
Add-Content $rep "<TH>H3SubH3</TH>"
Add-Content $rep "<TH>H3SubH4</TH>"
Add-Content $rep "<TH>H3SubH5</TH>"
Add-Content $rep "</tr>"
Add-Content $rep "<Body>"

Add-Content $rep "</Body>"
add-content $rep "</HTML>"
invoke-item $rep 

Open in new window

0
Comment
Question by:patelbg2001
  • 3
  • 2
6 Comments
 
LVL 18

Expert Comment

by:Raheman M. Abdul
Comment Utility
Best way is to use dreamweaver or any HTML generating software, then view source and then use the contents in powershell script.
0
 
LVL 6

Author Comment

by:patelbg2001
Comment Utility
I dont have access to those applications. whats an alternative method?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
Comment Utility
Just use <th rowspan="2">  on each of the cell that you want to be two rows.  

If that is not what you are trying to do, the perhaps an image of what you expect the table to look like would help,

Cd&
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 6

Author Closing Comment

by:patelbg2001
Comment Utility
I just created my table in excel and saved it in html format .
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
Comment Utility
Probably alright if it is for your own use, but if others use it expect complaints about the bloated slow thing you are giving them.  About the only worse HTML you can generate is using Word to generate.  

HTML coming out of Office is totally non-stand and will have compatibility issues even with MS browsers and other products.

Lots of luck.

I assume the C is because I was not prepared to write your code for you and you were not prepared to act/ually do anything to learn how to do things right.  It reflects more on you than on me.

Cd&
0
 
LVL 6

Author Comment

by:patelbg2001
Comment Utility
I'm not asking any one to write code for me, this is a learning a re-growth process. All I wanted was to work out structure, not content. So saving a table via excel in html format, and stripping out all the xml conversion junk left me with exactly what I needed to build a report to store data, which is emailed to Mr.X

Thanks to all that helped guide me.
B.
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
This article will help you understand what HashTables are and how to use them in PowerShell.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now