There are many reasons to generate Excel files from your website, mainly generating data reports.
As far as I know there are a couple of ways to generate Excel file from your web server regardless the platform:
- Component Server Side: There are several server-side components available to create excel files. Moreover, if you have MS Excel installed in your computer you can create excel files without third-party components.
-Client Side: If there's Excel installed in the client machine, a client vbscript can generate the file you need. I am not sure if it works under Firefox and, running client-side scripts can create a security hole in your system.
- XML Server Side. One nice feature of excel is that you can generate an excel file without the need of a component. That is, you generate an HTML-like document with the appropriate header and it will be available in Excel.
Well, this is just an introduction, not the subject of this post. I will focus on XML server side Excel file, but you will find several tutorials out there.
A friend of mine asked me how to rotate a text in a generated Excel file using the technique above. She was using the following style properties to accomplish that in HTML:
writing-mode: tb-rl; filter: flipv fliph;
Unfortunately it doesn't work in the excel file. Although Excel accepts HTML styles (CSS) to decorate the cells itself, the code above won't make your code appear vertical.
The following property will do the job if you want to rotate your text:
<td style="mso-rotate:90;">I Rotate</td>
As you can see, the property "mso-rotate:xx", specific to Microsoft products (mso) will rotate the text inside the cell (TD)
It wont only allow you to rotate the text vertical, but using any angle. Some people will prefer smaller angles instead of 90 as they are more readable.
If you want your Excel file look even better you should use "mso-" prefixed styles, they work like a charm.