![]() |
Range WrapText and AutoFit with Bold
Hi,
I'm formatting some data that I've loaded programmatically into a spreadsheet. I've started by calling WrapText on top row (the the column headings), then AutoFit on all of the columns. It looks like a nice start. Then I want the column headings to be bold, so I set Bold true on that range. I set it bold _before_ setting WrapText true and calling AutoFit, yet the text in the headings does not fit properly. The column widths are correct for a normal font, but bold makes the text occupy more pixels, so some long words are being broken at the last character. It looks like AutoFit ignores the fact that some of the text is bold. I'm working around this by adding 2 to each column's ColumnWidth. This looks nice for the sample data I've tried, but it's a kludge. I'd rather get AutoFit working properly. Is this a known bug? Is there a workaround? -- Peter Gummer |
Range WrapText and AutoFit with Bold
If your columns are skinnier than they need to be and wrap text is set, then
excel may not widen them. I like to select all my columns and make them as wide as they possibly could go. Then I autofit the columns. I also use alt-enters to force new lines within the cell so that lines break where I want them to break. Peter Gummer wrote: Hi, I'm formatting some data that I've loaded programmatically into a spreadsheet. I've started by calling WrapText on top row (the the column headings), then AutoFit on all of the columns. It looks like a nice start. Then I want the column headings to be bold, so I set Bold true on that range. I set it bold _before_ setting WrapText true and calling AutoFit, yet the text in the headings does not fit properly. The column widths are correct for a normal font, but bold makes the text occupy more pixels, so some long words are being broken at the last character. It looks like AutoFit ignores the fact that some of the text is bold. I'm working around this by adding 2 to each column's ColumnWidth. This looks nice for the sample data I've tried, but it's a kludge. I'd rather get AutoFit working properly. Is this a known bug? Is there a workaround? -- Peter Gummer -- Dave Peterson |
Range WrapText and AutoFit with Bold
Dave Peterson wrote:
If your columns are skinnier than they need to be and wrap text is set, then excel may not widen them. Yes, that does seem to be the case. Thanks for the suggestion. I tried calling AutoFormat on all columns, then setting Bold and WrapText, then calling AutoFormat again. The columns are now wider; but they're too wide! I've just tried something else: AutoFormat, with the Width option true. That isn't working either. I think I'll have to stick with my workaround. -- Peter Gummer |
Range WrapText and AutoFit with Bold
Did you use alt-enter to force new lines in the cell--where you wanted the lines
to break? I select all the cells on the worksheet (Ctrl-a few times). Then I use format|column|width|255 and hit enter then format|column|autofit (actually, I use double click on the column separator on the column header, but it does work for me. Peter Gummer wrote: Dave Peterson wrote: If your columns are skinnier than they need to be and wrap text is set, then excel may not widen them. Yes, that does seem to be the case. Thanks for the suggestion. I tried calling AutoFormat on all columns, then setting Bold and WrapText, then calling AutoFormat again. The columns are now wider; but they're too wide! I've just tried something else: AutoFormat, with the Width option true. That isn't working either. I think I'll have to stick with my workaround. -- Peter Gummer -- Dave Peterson |
Range WrapText and AutoFit with Bold
Dave Peterson wrote:
Did you use alt-enter to force new lines in the cell--where you wanted the lines to break? No, I don't want to do that. I'm loading data programmatically. The column headings will be different every time. Then I use format|column|width|255 and hit enter then format|column|autofit I can do that programmatically, but then the columns are too wide. I want the text to wrap without breaking words in the middle, widening the columns just enough to fit whole words but not the whole text. Thanks for the suggestions. -- Peter Gummer |
All times are GMT +1. The time now is 04:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com