-
Sep 20th, 2015, 09:44 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] How to add HTML tag <br> automatically fit table column width
The sample text is:
Code:
lRow = 3
lCol = 3
.Cell(lRow,lCol).Text = _
"Clipboard Support : " & vbNewLine & _
vbNewLine & _
" The grid content can be copied, cut and pasted freely." & vbNewLine & _
" The grid can interact with some other software such as Excel, it can copy & paste f/t Excel and smartly keep the cell attributes and styles. "
The column (lCol = 3) width is 400 pixels.
In Grid, the last long line can automatically break lines (Wrap text) by assign wFormat = DT_MODIFYSTRING Or DT_EDITCONTROL Or DT_NOPREFIX Or DT_WORDBREAK
But after I parse Grid content to HTML, the width of column 3 get too long showing in browser. The last column (lCol=3) got resized, the first column (lcol=0) got shrink.
If I delete the long line, the format are in good place. All column widths follow the assignment.
Code:
<body>
<table border=0 cellspacing=0 cellpadding=2 width=608 style="border-collapse:collapse">
<tr height=0>
<td width=40></td>
<td width=150></td>
<td width=18></td>
<td width=400></td>
</tr>
I already specify the table width but why browser parser differently?
Sure I can use hardcode by calculate width of every word then add <br>. Any better way (add some tags in HTML) to fix the column's width and the long line automatically wrap?
Code:
</tr>
<tr height=200>
<td class="s3 f2">Clipboard Support : <br><br> The grid content can be copied, cut and pasted freely.<br> The grid can interact with some other software such as Excel, it can copy & paste f/t Excel and smartly keep the cell attributes and styles. </td>
</tr>
Edited:
Post edited.
Last edited by Jonney; Sep 20th, 2015 at 07:40 PM.
-
Sep 20th, 2015, 10:05 AM
#2
Thread Starter
Frenzied Member
Re: How to add HTML tag <br> automatically fit table column width
attach the htm file
Edited: delete the attached HTML zip file to save my space (71KB) in VBForums.
If someone need it, please PS me.
Last edited by Jonney; Sep 21st, 2015 at 07:19 AM.
-
Sep 20th, 2015, 10:44 AM
#3
Re: How to add HTML tag <br> automatically fit table column width
How are you using the HTML?
Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.
-
Sep 20th, 2015, 07:07 PM
#4
Thread Starter
Frenzied Member
Re: How to add HTML tag <br> automatically fit table column width
Originally Posted by jmsrickland
How are you using the HTML?
ExportToHTML is a parser, output Grid content to HTML.
-
Sep 20th, 2015, 07:37 PM
#5
Thread Starter
Frenzied Member
Re: How to add HTML tag <br> automatically fit table column width
-
Sep 20th, 2015, 10:25 PM
#6
Thread Starter
Frenzied Member
Re: How to add HTML tag <br> automatically fit table column width
OK. Create the table and td style to specify our desired style.
Code:
<style>
table {border-collapse:collapse; table-layout:fixed; width:608px;}
table td {word-wrap:break-word;}
</style>
Last edited by Jonney; Sep 20th, 2015 at 10:29 PM.
-
Sep 20th, 2015, 10:47 PM
#7
Thread Starter
Frenzied Member
Re: How to add HTML tag <br> automatically fit table column width
Originally Posted by Jonney
OK. Create the table and td style to specify our desired style.
Code:
<style>
table {border-collapse:collapse; table-layout:fixed; width:608px;}
table td {word-wrap:break-word;}
</style>
improve further:
Code:
<style>
table {border-collapse:collapse; table-layout:fixed; width:608px;}
table td {white-space: -o-pre-wrap; word-wrap: break-word;white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; }
</style>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|