I
I
Ivan2017-07-06 07:34:11
Node.js
Ivan, 2017-07-06 07:34:11

Incorrect creation of .xls column width when using node.js and exel4node module?

In the project I use the excel4node module for node.js
The task is to set the width of the columns. Writing :

var width = 50;
ws.column(3).setWidth(width);

As a result, the width is 49.29.
In the source code of the module
I see the following code:
setWidth(w) {
        if (parseInt(w) === w) {
            this.colWidth = w;
            this.customWidth = true;
        } else {
            throw new TypeError('Column width must be a positive integer');
        }
        return this;
}

Looking at parseInt, I understand that it should take two parameters (a string and a number system)
parseInt(string, radix);
I change parseInt locally in column.js. The debugger shows that everywhere the value is "50" (as it should be) - and it behaved the same way before changing parseInt . But the output width is still not correct.
This is where my knowledge ends.
I understand that at some level there is a certain change in the data or the calculation system.
Questions:
1. Where to "dig" further?
2. Can I edit the source code of the module locally? (i.e. I corrected column.js - is it needed somewhere else?).
3. maybe someone has experience with the excel4node module ..

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2017-07-28
@Iv_and_S

never figured out what the problem is. decided as follows. in Column.js (in the sources of the exel4Node module) in setWidth disabled the parseInt() check (it is not correct at all, because it does not take into account a number of situations). And I set the values ​​of the columns empirically - by picking up the value.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question