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

Add autofilter or sort properties #472

Closed
nishthasb opened this issue Sep 29, 2016 · 4 comments
Closed

Add autofilter or sort properties #472

nishthasb opened this issue Sep 29, 2016 · 4 comments

Comments

@nishthasb
Copy link

Hi,

I have to do an export in excel where autofilter or sort is required. If i add similar as below code in xlsx.js or minified file, it works. But on server, we get the js-xlsx files from bower directly, so I can not use the locally edited files. Would you be willing to edit the files for filtering or sorting ?

In function write_ws_xml(idx, opts, wb) {
...
at line no 7562-->o[o.length]=writextag("autoFilter",null,{ref:ref});
...
}

@zuk38
Copy link

zuk38 commented Oct 14, 2016

Can You share example how to add autoFilter for header?

@nishthasb
Copy link
Author

Sure. Edit write_ws_xml(idx, opts, wb) function in xlsx.js or its minified, depending on which one is referred, and add the bold text in between the other code lines.

`if(o.length>sidx+1) { o[o.length] = (''); o[sidx]=o[sidx].replace("/>",">"); }

o[o.length]=writextag('autoFilter',null,{ref:ref});

if(ws['!merges'] !== undefined && ws['!merges'].length > 0) o[o.length] = (write_ws_xml_merges(ws['!merges']));`

@zuk38
Copy link

zuk38 commented Oct 14, 2016

Thank You! It's works fine!

I suggest send your changes as pull request.

@SheetJSDev
Copy link
Contributor

We're attaching the autofilter range as the ref key of the '!autofilter' key of each worksheet. In future commits we will add more features, but for now basic autofilters can be passed with:

We're pushing a change to add autofilter metadata in the worksheet !autofilter key. For now it just supports a reference, but later we will add more.

worksheet['!autofilter'] = { ref: "A1:C20" };

RimaCiklum pushed a commit to Folcon/js-xlsx that referenced this issue Aug 19, 2020
- XLSX/XLSB read/write autofilter
- XLS/XLML/*ODS read autofilter
- Workbook Properties override via Props option
- XLSB write sheet protection

Issues:
- fixes SheetJS#472 h/t @nishthasb
- fixes SheetJS#478 h/t @Yonatannn
- see SheetJS#623 h/t @jcarvin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants