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 does not work on OpenOffice #776

Closed
pandaadb opened this issue Feb 1, 2021 · 2 comments
Closed

AutoFilter does not work on OpenOffice #776

pandaadb opened this issue Feb 1, 2021 · 2 comments
Labels
confirmed This issue can be reproduced

Comments

@pandaadb
Copy link

pandaadb commented Feb 1, 2021

Description

Creating a simple autoFilter will not be displayed on OpenOffice, it is however displayed on Office365.

Steps to reproduce the issue:

Code:

        f := excelize.NewFile()

	f.NewSheet("sheet_test")
	for i := 0; i < 5; i++ {
		idx, _ := excelize.CoordinatesToCellName(i+1, 1)
		f.SetCellValue("sheet_test", idx, fmt.Sprintf("Header %d", i))
	}

	row := 2

	for j := 0; j < 10; j++ {

		for i := 0; i < 5; i++ {
			idx, _ := excelize.CoordinatesToCellName(i+1, row)
			f.SetCellValue("sheet_test", idx, fmt.Sprintf("Value %d", i))
		}

		row++
	}

	f.DeleteSheet("Sheet1")
	f.SetActiveSheet(0)

	f.AutoFilter("sheet_test", "A1", "E11", "")

	filename := "/tmp/test5.xlsx"

	f.SaveAs(filename)

Describe the results you received:

Xlsx file opens, however no fitlers are displayed in OpenOffice.
When uploading to Office365, filters are displayed.

Describe the results you expected:

OpenOffice to be able to display the auto filter.

Output of go version:

go version go1.13.10 linux/amd64

Excelize version or commit ID:

github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.2

Environment details (OS, Microsoft Excel™ version, physical, etc.):

Ubuntu 18.04
LibreOffice (LibreOffice 6.0.7.3 00m0(Build:3)

@xuri xuri added the confirmed This issue can be reproduced label Feb 1, 2021
@pandaadb
Copy link
Author

pandaadb commented Feb 1, 2021

Hi!

I am not sure if this helps, but I found that AddTable adds the filters to OpenOffice:

(it does not find the associated table style though I think)

xslxFile.AddTable(input.Name, leftUp, buttomDown, `{
		"table_name": "table",
		"table_style": "TableStyleMedium2",
		"show_first_column": true,
		"show_last_column": true,
		"show_row_stripes": false,
		"show_column_stripes": true
	}`)

@xuri xuri added the in progress Working in progress label Feb 2, 2021
@xuri xuri closed this as completed in 1f329e8 Feb 2, 2021
@xuri
Copy link
Member

xuri commented Feb 2, 2021

Thanks for your issue, I have fixed it, please try to use the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Feb 2, 2021
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- correct adjust calculation chain in duplicate rows
- correct adjust defined name in the workbook when delete worksheet
- use absolute reference in the auto filters defined name to make it compatible with OpenOffice
- API `CoordinatesToCellName` have a new optional param to specify if using an absolute reference format
- Fix cyclomatic complexity issue of internal function `newFills` and `parseToken`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed This issue can be reproduced
Projects
None yet
Development

No branches or pull requests

2 participants