Add autofilter or sort properties #472

Closed
opened 2016-09-29 08:20:02 +00:00 by nishthasb · 4 comments
nishthasb commented 2016-09-29 08:20:02 +00:00 (Migrated from github.com)

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});
...
}

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 commented 2016-10-14 08:59:15 +00:00 (Migrated from github.com)

Can You share example how to add autoFilter for header?

Can You share example how to add autoFilter for header?
nishthasb commented 2016-10-14 09:10:18 +00:00 (Migrated from github.com)

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']));`

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] = ('</sheetData>'); 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 commented 2016-10-14 09:55:41 +00:00 (Migrated from github.com)

Thank You! It's works fine!

I suggest send your changes as pull request.

Thank You! It's works fine! I suggest send your changes as pull request.
SheetJSDev commented 2017-04-10 05:21:26 +00:00 (Migrated from github.com)

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" };
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. ```js worksheet['!autofilter'] = { ref: "A1:C20" }; ```
Sign in to join this conversation.
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sheetjs/sheetjs#472
No description provided.