V
V
Vitaly Petrov2015-01-25 16:58:43
PHP
Vitaly Petrov, 2015-01-25 16:58:43

SheetJS/js-xlsx and file formatting?

Hey!
My head is already splitting, my nerves are on edge, and I still couldn’t achieve the result in two days of work =(
Please help me with advice)
In general:
1) There is an application on Meteor (I decided to figure out what and how with it, file a small project, before that I had no experience working with it, or with node, npm, mrt, bower, etc., on the web I wrote everything in Yii);
2) There is a sample.xlsx file located on the server;
3) There is a library for parsing XLSX in JavaScript. It is called SheetJS, it can work both on the client and on the server (node, that's all).
The task is as follows:
1) When you click on the button, we download from the server to the client the sample.xlsx file template, in which formatting is specified- this is described in the standard SheetJS documentation, done via XMLHttpRequest, nothing complicated;
2) We change something in the file - it also seems to be more / less clear;
3) Save the file to the user's computer. This is where the root of the problem lies - the file is saved to the user's computer without any formatting whatsoever. That is stupid - the standard Excell markup and a bunch of text scattered throughout the table.
Actually, my questions are:
1) I am a sinner, I could not fully understand the SheetJS source code and the XLSX format. Perhaps this is normal behavior for SheetJS and is only meant for parsing/parsing, but not for normal XLSX saving?
2) Perhaps I did not see some option somewhere?
3) Are there other adequate libraries for working with XLSX in JavaScript? As far as I can understand, no.
4) Should I give up on the idea of ​​parsing/saving an Excel template using JS and just file everything as a separate web service for the current project in PHP and PHPExcel? It will be easy, but ... then what for Meteor and others like him?
5) Or maybe you should change the format of the source and final file to PDF? But here I don’t know either ... what library can work on a pdf template? In which application to make a pdf template?
Actually, I'm now leaning towards the latter option, as the most appropriate.
I cannot refuse to create Excel documents, as this will lead to the senselessness of the implementation of the entire project in general. And I have already done a lot there and I am going to complete the undertaking, although I repeat - there is already a desire to break the monitor with the keyboard, and also come personally to each SheetJS developer and ... talk about adding the functionality I need.
In general, the library itself looks like some kind of handicraft on the knee, but people praise it ...
Link to the library: https://github.com/SheetJS/js-xlsx
Fuh, here, I kind of spoke out. Guys, please help with advice.
Here are examples of the initial:
ead215ea456148a0be18aac508d4f2a1.png
... and the final file:
c6d445b727e5481e8ea869b8057308f1.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pomeo, 2015-01-28
@vitaly_KF

I have been actively working with Excel from a node for the last month and have used js-xlsx exclusively for parsing. This module went very well to create https://github.com/natergj/excel4node . Formatting in it is set very easily. Memory consumes much less than all the others.

V
Vlad Timofeev, 2015-01-25
@PyTiMa

https://www.npmjs.com/package/node-xlsx may be more adequate.... this is a wrapper for Node on js-xlsx.
When I see their code examples on the github js-xlsx - I'm torn, sorry for the harshness)

S
squall123, 2019-03-28
@squall123

I also fiddled with this problem for a long time, but in the end I found a solution. Here is a good package for editing excel files in node.js: https://github.com/exceljs/exceljs
Really good package.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question