Creating a XLS in Classic ASP or VB6


Does anyone know how to create a .xls file in VB6 or Classic ASP without having Excel installed on the machine?

In addition, as these .xls files must be readable by Excel Viewer, which doesrn't read read HTML / MIME type files, so it must be true .xls files.

Thank you.
APD TorontoAsked:
Who is Participating?
rentoncConnect With a Mentor Commented:
Incorrect, the viewer will read the .xls file perfectly as I am using the very same system here.

Filesystemobject saves the .xls file (which is built up with tables) and the viewer reads it perfectly. This way you don't need to install OWC on the server.
You can use filesystemobject to create a text file and name it with the extension .xls.
Fill the file with HTML tables and content, these will be viewable within Excel.
aprestoConnect With a Mentor Commented:
This is also known as a CSV. If you want an actual XLS file see here:
Unless i have been away so long that i have missed something :) You will need an external COM component to achieve this,
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Yes Apresto, but this method outputs directly to page as an Excel file opened within the browser, not to an Excel file saved on the server. I use both methods in many systems.
APD TorontoAuthor Commented:
I need to deliver to the user a formatted xls sheet readable also by Excel Viewer.  So csv won't work, and Viewer doesnt read HTML.

How could I use OWC in ASP or VB6?  I have tried the code below in VB6 but I can't find the reference?

In HTML I placed it within <script> tage, it gives me ActiveX can't create object: 'owc.spreadshee'
Dim objS As Object
Set objS = CreateObject("owc.spreadsheet")
'Build Header
objS.cells(1, 1).Value = "Project"
objS.cells(1, 2).Value = "Tasks Completed"
objS.cells(1, 2).Value = "Last Status Date"
'Add a row of data
objS.cells(2, 1).Value = "MyProject"
objS.cells(2, 2).Value = "5/6" 'Want this to appear in the spreadsheet as a fraction.
objS.cells(2, 2).Value = "2006-05-11 10:21 am" 'Want this to appear as a date and time
objS.activesheet.Export "c:\temp.xls", 0
End Sub

Open in new window

Ah, i think it could be that owc isnt installed on this server. you can download it from here:


Open in new window

APD TorontoAuthor Commented:

Are you sure, I have the code below.  The full Excel reads it, but Excel Viewer givse me "Microsoft Excel Viewer cannot open files of this  type".  I'm using Excel Viewer 2003 (11.8237.8221) SP3.

Please help?
<%@ Language=VBScript %>
      'Change HTML header to specify Excel's MIME content type
      Response.Buffer = TRUE
      Response.ContentType = "application/"
      FPath = "c:\" & fn 
      Response.AddHeader "Content-Disposition", "attachment; filename=123.xls" 
   <html xmlns:o="urn:schemas-microsoft-com:office:office"
     {mso-header-data:"&XX Day Absence Report\000ADate\: &D\000APage &P";
	  mso-page-orientation:landscape; }
	<!--[if gte mso 9]><xml>
   <!-- Our table which will be translated into an Excel spreadsheet -->
			style="border-right-style: solid; border-right-width: 2;
        		   border-left-style: solid; border-left-width: 2;
        		   border-top-style: solid; border-left-width: 2;
        		   border-bottom-style: solid; border-left-width: 2">
  <tr><td WIDTH="145"> <b> # </b> </td> </tr>
 <% For i = 1 To 500 %>
	<tr><td> <%=i%> </td> </tr>
<% Next %>

Open in new window

You have to save the file to disk first, currently you are streaming the content you create as a excel document type.

In its simplest for, if you saved a file called example.xls with the code below in it, it would open within the viewer.

Try it and let me know, because this works for me on our excel viewers
<th>Heeading 1</th>
<td>Result 1</td>

Open in new window

APD TorontoAuthor Commented:
I copied your code in Notepad and saved as both as .htm and as .xls... Excel reads it, Viewer does not.  Same error.
Can you give me the link where you got your viewer?  Mine may be corrupt, but i did get it from
APD TorontoAuthor Commented:
Which Version of Excel Viewer are you using?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.