I have gone through this page: https://help.salesforce.com/apex/HTViewSolution?id=000003176 and successfully exported my data into excel sheet with .xls format. However, I kind of want to achieve a bit fancier effect in Excel. Something like this:
As you can see, the columns support filtering and sorting and there are colors in the spreadsheet. Is there anyway I can achieve this – even if Visualforce page with contenttype is not an option. The link to any related API/documents would also be helpful. And hopefully I don't need to go into Encoding.
Best Answer
Funny you should ask this - I just submitted a blog yesterday that deals with this. Unfortunately, the blog has not been approved for publishing yet. The short version of the blog is
Your controller will look something like this:
The reason you should do this in Excel is that the styles syntax that Excel generates is, to put it bluntly, horrible. Here is the sort of thing you get:
...and on and on. No style names. repetition. Yuk.
Any formats you save in the spreadsheet will be maintained on the next export. Obviously you are going to have to add repeats and other apex data.
For my working code page, take a look here