Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoFilter not apply default #1730

Open
xx1196 opened this issue Nov 25, 2023 · 1 comment
Open

AutoFilter not apply default #1730

xx1196 opened this issue Nov 25, 2023 · 1 comment

Comments

@xx1196
Copy link

xx1196 commented Nov 25, 2023


548 / 5,000
Resultados de traducción
Traducción
I have the following code: // Add headers to the Excel file
headers := []string{"ID", "Status", "Product", "Cost", "# of people", "Order", "Start Date"}
// Set auto filter for the headers
err = xlsx.AutoFilter(sheetName, fmt.Sprintf("A1:%s1", columnIndexToAlpha(len(headers))), []excelize.AutoFilterOptions{
{Column: "B", Expression: "x = paid"},
})
if err != nil {
return err
}

which applied a filter in column B where = a paid, when the excel loads it looks like this (all the data without the filter)

image

I have to click on the filter (I see that the paid option is checked by default) and click on apply, if the filter works, am I doing something wrong? I appreciate your help

@xuri
Copy link
Member

xuri commented Nov 29, 2023

Thanks for your issue. This library doesn't support filtering cell values when you add an auto filter. As the documentation says: It isn't sufficient to just specify the filter condition. You must also hide any rows that don't match the filter condition. Rows are hidden using the SetRowVisible function. Excelize can't filter rows automatically since this isn't part of the file format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants