Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTML Code for excel type fixed column display

Status
Not open for further replies.

tmk07

IS-IT--Management
Jul 2, 2007
5
US
I am having trouble to translate the csv format output into html format display. I used table/cell padding and even use non-printing char such " " but still unable to align heading column with the data column

Here is my problem
|Text-Column1 |Text-Column2 |Int-Column3|Float-Column4|
|data12345 |data32|45|0.0|
|datxc |fgtr56dfg4|56789|0.99887772|

Any solution to this problem will be highly appreciated
 
Code:
awk -F"|" 'BEGIN {print "<table>"} ; {  print "<tr><td>" $1 "</td><td>" $2 "</td><td>" $3 "</td><td>" $4 "</td></tr>"} ; END { print "</table>"}' data.txt

Produces

<table>
<tr><td></td><td>Text-Column1 </td><td>Text-Column2 </td><td>Int-Column3</td><td>Float-Column4</td><td></td></tr>
<tr><td></td><td>data12345 </td><td>data32</td><td>45</td><td>0.0</td><td></td></tr>
<tr><td></td><td>datxc </td><td>fgtr56dfg4</td><td>56789</td><td>0.99887772</td><td></td></tr>
</table>

from your data

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
I have a similar code but problem is that the variable length data never fits into fixed length table cells. The table cell expand & shrink by the length of the data it contains. I want it like excel format where any length of data stays within the fixed length header colum
 

I don't see any way to copy screenshot here to provide detail on what I am looking for in terms of HTML table misalignment with the data

 
So you want to truncate cells to say 8 chars or you want to expand cells to whatever the largest is?

Guessing this is the problem you have?

Text-Column1 Text-Column2 Int-Column3
data12345 data32 45
datxc fgtr56dfg4 56789
datxcfdfdfdfdfdfdfdf fddfdfdfdfdfdfdfgtr56dfg4 5575755757575756789



Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
Thanks MRN. You solved my problem. I was trying to align two different table cells together.
Much appreciated
Tmk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top