简体   繁体   中英

Creation for excel file in classic asp

I created a excel file in classic asp with the following code.

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = TRUE
objExcel.Workbooks.Add

Set objWorksheet = objExcel.Worksheets("Sheet2")
objWorksheet.Activate

objWorksheet.Cells(1, 1).Value = "A"

I have got the following error.

Microsoft Office Excel (0x800A03EC)
Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. • To make more memory available, close workbooks or programs you no longer need. • To free disk space, delete files you no longer need from the disk you are saving to.

How can I solve this? Thanks.

Instead of creating an instance of Excel to create the file (an approach I've always found to leak memory and ultimately fail from Classic ASP), I'd suggest you consider outputting the data as a big HTML table, and force the browser to open it in Excel using the following at the start of your response:

<%
response.ContentType = "application/vnd.ms-excel"
response.AppendHeader "content-disposition", " filename=export.xls"
%>

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