VB, .NET, SQL Server, MOSS
Programming for life!
Serving the web community
with my knowledge

When you have Excel installed on your system, the .xls extension is registered with the Excel application. In other words: when you double-click a file with the .xls-extension, or open it from Internet Explorer, Excel opens the file.
You can easily generate Excel-files from all your applications, without any API or other dependancy like Office. Simply write a text file with the extension .xls, and use the TAB character as field delimiter, and newline as line delimiter. From VB or ASP, use chr(9) and vbNewline. From C#, use \t and \r\n.
After writing the file, you can automatically open it, by using a Shell from VB, or write the file to the browser output with the correct MIME type in the HTML header. (note that for ASP/ASP.NET applications, you don't even have to write a temporary file; you can also build a string, and write it to the browser)
The advantage of this method compared to CSV format is, that the delimiter in CSV is dependant of your region. With the Dutch regional settings, you need a semi-colon (;), whereas the US/British regional settings use a comma (,).
The only drawback for this method is, that you can't use things like multiple sheets, lay-out, formulas and so on. But it is still very useful.
'write an Excel-file Open "c:\example.xls" For Output As #1 Print #1, "Line 1" & vbTab & "Field A" & vbTab & "Field B" & vbTab & "Field C" Print #1, "Line 2" & vbTab & "Field A" & vbTab & "Field B" & vbTab & "Field C" Print #1, "Line 3" & vbTab & "Field A" & vbTab & "Field B" & vbTab & "Field C" Close #1 'open the newly created Excel-file Shell "c:\example.xls"
Line 1 Field A Field B Field C Line 2 Field A Field B Field C Line 3 Field A Field B Field C
Last modified on: 2005-12-09