How to apply auto-filter in ASP classic

EasyXLS Excel library can be used to export Excel files in Classic ASP. The library is a COM+ component that works without MS Excel installed.

Step 1: Download and install EasyXLS Excel Library for .NET

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for ASP Classic

If you already own a license key, you may login and download EasyXLS from your account.

Step 2: Verify if EasyXLS is registered

Check if EasyXLS component is present in Component Services.

Step 3: Run ASP code that applies auto-filter to Excel data

Execute the following ASP code that exports data with autofilter to Excel.

<%@ Language=VBScript %>

<!-- #INCLUDE FILE="DataType.inc" -->

' Tutorial 20
' This tutorial shows how to create an Excel file in ASP classic
' and apply an auto-filter to a range of cells.

response.write("Tutorial 20<br>")

' Create an instance of the class that exports Excel files
set workbook = Server.CreateObject("EasyXLS.ExcelDocument")

' Create a sheet

' Get the table of data for the worksheet
Set xlsTab= workbook.easy_getSheet("Sheet1")
Set xlsTable = xlsTab.easy_getExcelTable()

' Add data in cells for report header
for column = 0 to 4
    xlsTable.easy_getCell(0,column).setValue("Column " & (column + 1))

' Add data in cells for report values
for row = 0 to 99
    for column = 0 to 4
        xlsTable.easy_getCell(row+1,column).setValue("Data " & (row + 1) & ", " & (column + 1))

' Apply auto-filter on cell range A1:E1
Set xlsFilter = xlsTab.easy_getFilter()

' Export Excel file
response.write("Writing file: C:\Samples\Tutorial20 - autofilter in Excel sheet.xlsx<br>")
workbook.easy_WriteXLSXFile ("C:\Samples\Tutorial20 - autofilter in Excel sheet.xlsx")

' Confirm export of Excel file
if workbook.easy_getError() = "" then
    response.write("File successfully created.")
    response.write("Error encountered: " + workbook.easy_getError())
end if

' Dispose memory

Overloaded methods
For methods with same name but different parameters, only the first method overload retains the original name. Subsequent overloads are uniquely renamed by appending to the method name '_2', '_3', etc (method, method_2, method_3), an integer that corresponds to the order of declaration that can be found in EasyXLS.h, a file that comes with EasyXLS installation.

EasyXLS Excel components:

Excel Library for ASP classic
full COM+ version to import, export or convert Excel files
Excel Writer for ASP classic
COM+ version to create and export Excel files
Download EasyXLS™ Excel Component for ASP classic

File formats:

MS Excel 97 - 2003
MS Excel 2007 - 2010
MS Excel 2013
MS Excel 2016
MS Excel 2019