Comments (5)
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.
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.
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.
Any updates on this?
Have you guys worked on this
from excel4node.
has anyone managed to adjust the width of the cells yet?
from excel4node.
Related Issues (20)
- Date format is not changing HOT 1
- Write to Existing File
- Is this project dead? HOT 3
- addDataValidation list dropdown not working when formula is string too long HOT 1
- Solved: creating a buffer
- How can we handle regx or patterns?
- Heap out of memory for a non-formatted, 100k row file
- Set width and height in pixels and center image in cell
- Hard crash electron when writing file
- empty number cell
- Add ESM Support HOT 1
- mergeCells function improvement
- excel4node and Azure Functions HOT 1
- handling exceptions for error wb.write()
- Jszip audit issue
- Get the binary code of excel and return it without express.js
- Worksheet print option. "Scale to fit" flag HOT 1
- How to avoid overwriting the previous data?
- Cannot save file locally
- Dependency jszip update HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from excel4node.