Giter Club home page Giter Club logo

Comments (5)

natergj avatar natergj commented on August 16, 2024

I was asked by one of the people who use the spreadsheets that are created by the library if I could update it to do just this.
It certainly is possible, but the solution I could think of is not great and basically involves using system tools to render the font string in order to account for font size, face and decoration and measuring that. I don't like this solution because it relies on the system which is different for different developers. I haven't found a good server-side solution in pure javascript since every solution I have found relies on the browser's DOM.
If I could find an efficient way of measuring the width of a font string in pure javascript, I would then need to find an efficient way of finding the longest string. I'm thinking it would involve separating the strings of a column into different array of different styles, finding the longest string in each array, calculating the width of each longest string and then using the longest width for the column width. This would happen during the xl.write() process. I think this would be efficient enough to not cause a significant increase in the time taken to generate the excel file that would outweigh the benefit given.
I'm going to mark this as an enhancement request. If you know of or can think of an efficient way to measure the width of a string once it has been rendered, then please let me know.

from excel4node.

lvarayut avatar lvarayut commented on August 16, 2024

Thanks @natergj for the great response. I agree with your second approach that we could find the longest string that a user has put in each column and also a style applied to the column during the xl.write() process. This could make us roughly know that how much width in each column we should set for the user.

When I have time, I will try to implement this approach and see if it works.

from excel4node.

natergj avatar natergj commented on August 16, 2024

just an FYI. tomorrow night I'm planning on merging my dev branch into master. It is a complete refactor which takes care of quite a few inefficiencies and cleans up some mess of some hastily written code of the current master. you'll want to update your fork.

from excel4node.

code-blooded-developer avatar code-blooded-developer commented on August 16, 2024

Any updates on this?
Have you guys worked on this

from excel4node.

giordifungula avatar giordifungula commented on August 16, 2024

has anyone managed to adjust the width of the cells yet?

from excel4node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.