bhima icon indicating copy to clipboard operation
bhima copied to clipboard

Fix Excel Report exporter

Open jmcameron opened this issue 3 years ago • 2 comments

In the server, when we generate an 'xlsxReport', it appears to work, but the resulting seems to be corrupted. When you open the resulting Excel file, it complains: image

If you say yes, the result seem to be okay. Not sure what is going on.

However, the 'xlsx' export works without problems.

  • See Stock > Stock Lots > Menu > Download as Excel

To reproduce the problem:

  • Stock > Articles in Stock
    • Verify that the export type is 'xlsxReport' (line 312 client/src/modules/stock/inventories/registry.js)
    • download: Stock > Articles in Stock > Menu > Download as Excel
    • Open the downloaded file and see the error message

jmcameron avatar Jan 20 '22 19:01 jmcameron

Yeah, this is because the XLS export isn't actually an XLS export - it is an HTML file renamed to XLSX. We probably should figure out something better on the long run.

One issues is that the xlsx library we use doesn't support styling cells - I believe it is a paid feature. excel4node does, but it doesn't appear to be maintained anymore. It would be worth us reflecting on it and choosing a single library for our exports that supports all our needs.

jniles avatar Jan 21 '22 07:01 jniles

See related Issue https://github.com/IMA-WorldHealth/bhima/issues/6342

jmcameron avatar Jan 25 '22 20:01 jmcameron