%@ Language=VBScript %> <% if Request("type")<>"" then set dbConnection = server.CreateObject ("ADODB.Connection") dbConnection.ConnectionString = strConnection dbConnection.Open strSQL = Session(strTableName & "SQL") sWhere = "" if Instr(lcase(strSQL), " where ") > 1 then sWhere = Mid(strSQL, Instr(lcase(strSQL), " where ")) strSQL="select " & AddWrappers("Cod") & ", " & AddWrappers("Nome") & ", " & AddWrappers("Descrizione") & ", " & AddWrappers("Prezzo") & ", " & AddWrappers("prenotato") & ", " if Right(strSQL,2)= ", " then strSQL = Left(strSQL, Len(strSQL)-2) strSQL = strSQL & " from " & strTableName & sWhere Set rs = server.CreateObject ("ADODB.Recordset") rs.Open strSQL, dbConnection if Request("records")="page" then ' Pagination: if NOT rs.EOF then mypage = Request("mypage") rs.PageSize = Request("pagesize") maxRecords = cdbl(rs.RecordCount) maxPages=cdbl(rs.PageCount) if cdbl(mypage) > cdbl(maxPages) then mypage = maxpages End IF rs.AbsolutePage = mypage maxrecs=cdbl(rs.pagesize) End IF end if Response.Expires=0 ' prevent caching Response.Buffer=True Server.ScriptTimeout = 120 if Request("type")="excel" then Call ExportToExcel elseif Request("type")="word" then Call ExportToWord elseif Request("type")="xml" then Call ExportToXML elseif Request("type")="csv" then Call ExportToCSV end if rs.Close set rs=Nothing dbConnection.Close set dbConnection = Nothing Response.Flush Response.End else %>
<% Response.End end if Sub ExportToExcel Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment; Filename=Prodotti.xls" Response.Write "" Response.Write "