Solved

Powershell HTML Table

Posted on 2014-04-08
6
439 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 19

Expert Comment

by:Raheman M. Abdul
ID: 39985598
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
ID: 39985727
I dont have access to those applications. whats an alternative method?
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 500 total points
ID: 39987253
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
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 6

Author Closing Comment

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

Expert Comment

by:COBOLdinosaur
ID: 39997457
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
ID: 40003748
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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

729 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