How do I reduce the width of the cell which is longer
I am generating the Html in Excel sheet and entire table is fine and except the two cells are much wider. How do I reduce the width of those cells. I tried chan开发者_运维知识库ging the width and everything but no use. It works fine on Html table. On Excel spreadsheet it looks different.
Well, Chrome v6.0.472.62 and Firefox 3.6.10, both on Ubuntu 10.04, allow:
th, td {width: 7em; max-width: 8em; }
the max-width
seems to be the important part, preventing the cell from growing. Also the white-space: nowrap
is important if you don't want the cell to wrap the contents within the defined width
.
There's a demo over at jsbin.com, I've not hidden the overflow on the overflowing cell, deliberately so that you could see it in effect, though in real use you'll need to work out some way of showing the actual contents of the cell without it obscuring the content of its neighbours.
Since its a HTML table, just two cells cant be big. its either one entire row bigger or one entire column bigger.
If that is the case, the dimensions are best-fit based on the content of those cells. Therefore, the width attribute won't take effect. if wordwrap is not helping, changing the fontsize of that exact cell alone can help you.
Something else to check: make sure that you're outputting the proper number of cells per row taking careful account of row/col spanning. If you miss one somewhere, the whole thing will be screwy.
精彩评论