Tuesday, October 03, 2006
Inserting a table via DOM in Internet Explorer
I just wasted two hours of my life trying to find out why a table I'd build up using DOM methods wasn't displaying in IE. I was building a table like this:
..but my table wasn't showing in IE (Firefox was fine). I could and see my table source, and unbelieveably, if I did a my table would show up (but any events were lost).
Well it turns out that if you don't explicitly add a tbody element, IE won't show your table. I found that out here.
Grr!
Monday, April 10, 2006
Force an Excel column to upper case
This is a sweet little trick that took ages to work out.
Usually when you're working with stuff in Excel you capture raw data in one column, and then write formulae to clean that data and serve up the cleaned version in another column for use.
Sometimes though, you just can't do that. Here's a how-to for letting your users type whatever random rubbish they want into a column, and then cleaning the data right there in the cell they typed into.
For this example I'll demonstrate making a column uppercase, but the trick is fairly generalisable.
As it stands, this code will capitalise anything typed into column A, except for cell A1. You can easily change what cells and columns are covered, and what the thing actually does to cells that are included. To fiddle with which columns are covered, change line 6. Eg if you want columns C, D, E and F (ie columns 3 to 6, change it to:
If you want to affect just row 12, change line 7 to something like:
If you want to affect the whole column, you can delete lines 7 and 9 completely.. etc etc.
Usually when you're working with stuff in Excel you capture raw data in one column, and then write formulae to clean that data and serve up the cleaned version in another column for use.
Sometimes though, you just can't do that. Here's a how-to for letting your users type whatever random rubbish they want into a column, and then cleaning the data right there in the cell they typed into.
For this example I'll demonstrate making a column uppercase, but the trick is fairly generalisable.
- Make sure you've saved the workbook somewhere (weirdly, in an unsaved workbook, this trick silently fails)
- Hit Alt-F11 to get the Visual Basic editor up
- in the Project pane on the left, double-click on the name of the sheet you want to apply the effect to, eg Sheet1
- Paste the following code into the blank window that opens up:
As it stands, this code will capitalise anything typed into column A, except for cell A1. You can easily change what cells and columns are covered, and what the thing actually does to cells that are included. To fiddle with which columns are covered, change line 6. Eg if you want columns C, D, E and F (ie columns 3 to 6, change it to:
If you want to affect just row 12, change line 7 to something like:
If you want to affect the whole column, you can delete lines 7 and 9 completely.. etc etc.
Tuesday, March 07, 2006
Excel: That annoying paintbrush button (a.k.a. "Insert Options")
Someone asked me how to get rid of the "Insert Options" button. Here's what he was getting; I've highlighted the button in this image:
You get this when you insert a row. Excel is asking what formatting you want for your new row (you can choose to copy formatting from the row above or the row below). Even when you make a choice, however, the button stays on screen, forever obscuring nearby data (you can click in another cell and the buttons stays there -- to get rid of it you have to actually edit a cell).
So, here's how to get rid of it:
You get this when you insert a row. Excel is asking what formatting you want for your new row (you can choose to copy formatting from the row above or the row below). Even when you make a choice, however, the button stays on screen, forever obscuring nearby data (you can click in another cell and the buttons stays there -- to get rid of it you have to actually edit a cell).So, here's how to get rid of it:
- In the Tools menu, choose Options.
- Select the Edit tab.
- Un-check the box next to "Show Insert Options buttons".
Tuesday, November 15, 2005
XSLT: Padding text output to the right width
I'm writing some XSLT that is supposed to generate a text file.
I thought I needed to pad the fields with spaces to get them to the right width, but actually I don't, it is delimited text not fixed width.
Thought I better post this somewhere I can find it again if I need to :)
There's two named templates (read, functions), "spaces" that returns a specified number of spaces (up to 255), and one that uses spaces to do truncation or left-justification. Call it like this:
and the result will be the text "this is too short" with 23 spaces after it (making it 40 chars long).
Thought I better post this somewhere I can find it again if I need to :)
There's two named templates (read, functions), "spaces" that returns a specified number of spaces (up to 255), and one that uses spaces to do truncation or left-justification. Call it like this:
and the result will be the text "this is too short" with 23 spaces after it (making it 40 chars long).