webodf / ViewerJS

ViewerJS: Document Reader in JavaScript
http://viewerjs.org
1.94k stars 421 forks source link

ODS documents look kinda broken #289

Open rorp24 opened 4 years ago

rorp24 commented 4 years ago

I have some troubles using viewerJS with ODS documents. The document look kinda broken. Even if I understand as a developper what is going on, my users won't like that.

image

the original version of the ODS:

image

I find a way to show the data, with SheetJS, but I think it is sad that a library that is not supposed to work with ODS documents work better than a library that is supposed to work with those documents

rendered html with SheetJS:

image

used code with SheetJS: var request = new XMLHttpRequest(); request.open('GET', uri, true); request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); request.responseType = 'blob'; request.onload = function(e) { if (this.status === 200) { var blob = this.response; blob.arrayBuffer().then(res=>{ var workbook = XLSX.read(res, { type: "array" }); var worksheet = workbook.Sheets[workbook.SheetNames[0]]; $('.showView div').html(XLSX.utils.sheet_to_html(worksheet)); }); } }; request.send();