tags:

views:

68

answers:

3

Iam 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 treid changing the width and everything but no use .:It works fine on Html table .On excel spread sheet it looks different

A: 

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.

thevikas
A: 

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.

Brad
+1  A: 

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.

David Thomas