2

I have been exporting excel files using application/vnd.ms-excel option in classic ASP but after downloading when I click Save As I see Save As Type option = web page.

So is there any way to Save As by default so the file type can be saved as an "Excel 97-2003 WorkBook"? I tried excel.application and owc but unfortunately neither work for me.

Actually, these options are consuming a lot of CPU memory when I use them.

I am open to using any third party component for excel creation.

Thanks.

ckpepper02
  • 3,297
  • 5
  • 29
  • 43
Ravi Bhartiya
  • 299
  • 2
  • 9
  • 20
  • You should be able to use the same file types here: http://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc – ckpepper02 May 15 '13 at 23:12
  • I used to use office writer (http://www.officewriter.com) for this. Expensive but very good. The only problem is they have dropped support for classic asp. – Jon P May 15 '13 at 23:59
  • Sounds like your code is erroring and sending back a HTTP 500.100 which will be `text/html` (web page) content type rather than your expected `application/vnd.ms-excel`. – user692942 Jul 16 '13 at 14:33

1 Answers1

0

I am not sure if you are aware but you can access the Excel DOM using classic ASP as long as you have Excel installed on the web server.

There are limitations to what you can do but if your requirements are simple then it might be the answer you are looking for without the need to purchase expensive components which are starting to become unsupported.

Set oExcel = Server.CreateObject("Excel.Application")

Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.ActiveSheet
Set oRange = oExcel.ActiveCell

oRange.Cells(1,1) = "First Column"
oRange.Cells(1,2) = "Second Column"

oBook.SaveAs "workbook.xls"
oBook.Close
oExcel.Quit

Set oExcel = Nothing
Mike Poole
  • 1,958
  • 5
  • 29
  • 41