clarketm / TableExport

The simple, easy-to-implement library to export HTML tables to xlsx, xls, csv, and txt files.
https://tableexport.travismclarke.com/
Apache License 2.0
888 stars 289 forks source link

XLSX is disabled in mobile devices #131

Closed esaesa closed 6 years ago

esaesa commented 6 years ago

This sample https://tableexport.v3.travismclarke.com/examples/exportButtons.html and its modified v5 is not showing the xlsx button with a console warning tableexport.min.js:19 "xlsx" requires "js-xlsx".

image

I searched the code and i found

var _isEnhanced = (function () {
        return function (key) {
            return (
                XLSX
                && !_isMobile
                && !(TableExport.prototype.formatConfig[key].enforceStrictRFC4180)
            );
        }
    })();

which will return always false in mobile devices and so generate the error as dependency is required although it is loaded correctly and working in other older examples. You can note in the image only two buttons instead of 3 as desktop version.

Update: 25,Apr. 2014


clarketm commented 6 years ago

@esaesa – I will investigate because this doesn't look correct. I will acknowledge that mobile support is not fully cross-platform (e.g. Safari mobile and some of the less common/popular mobile browsers). At the end of the day, this data is generated client-side, so full compatibility is not feasible, but most major mobile browsers should be supported, or this is a bug.

Now that I can recall, xlsx/ xls was so inconsistent on mobile browsers that it was disabled untill support could be delivered in a safe, consistent manner. I may have a fix but extensive cross-platform (and cross device) testing will be needed before I can safely add this support. Both csv and txt are fully supported, so logic can be added for mobile environments either in TableExport or in the implementation until this can be resolved. Sorry for the inconvenience.

The error "xlsx" requires "js-xlsx". is specifically related to a missing dependencies, so there is something 🐟y going on here (to your point about _isMobile check) and this error is misleading ... the purpose was originally to short-circuit the execution (hence why the button is not added for xlsx). There was a known issue with dataURIs on iphone (xlsx & xls) and native mobile browser support for Blob which may no longer be a problem. Either way, the issue(s) on mobile related to xls and xlsx need to be triaged and addressed. This will be fixed in the next minor release. Thanks for you help!