简体   繁体   中英

How to create real excel file in Classic ASP

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM