Posted 8 June 2021, 5:16 am EST
Alt+Enter adds a line while editing as expected but the final output is all on one line (unlike 365 where the output is shown on 2 lines).
Can this be fixed to match Excel?
Forums Home / Spread / SpreadJS
Posted by: mwyatt on 8 June 2021, 5:16 am EST
Posted 8 June 2021, 5:16 am EST
Alt+Enter adds a line while editing as expected but the final output is all on one line (unlike 365 where the output is shown on 2 lines).
Can this be fixed to match Excel?
Posted 8 June 2021, 7:44 pm EST
Hi,
This expected behavior from SJS in order to wrap the content in a cell you need to use the word wrap method and set it as true. Please refer to the following code snippet and attached sample that demonstrates the same.
activeSheet.getRange(0, 0, 5, 5).wordWrap(true);
activeSheet.setValue(0, 0, "Hello \nnewLine");
sample: https://codesandbox.io/s/pedantic-liskov-t0hgf?file=/src/index.js:323-422
API References:
wordWrap: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.CellRange~wordWrap.html
Regards,
Avinash
Posted 11 January 2022, 12:38 am EST
Hello,
We are still having issues with this. Excel turns word wrap on cells that contains new lines when the user enters data. However, Spread JS does not reflect this behavior. We have been discussing our options.
We thought about enabling word wrap at sheet level but we’ll need to apply this for the import functionality and for every sheet in a workbook which is really expensive in terms of coding. Another approach would be something like intercepting the cell edition event to identify if the user entered a new line character and activate the word wrap for that cell. The application behaves different than what it should.
Here is some sample code that explains what we want to achieve:
https://codesandbox.io/s/pedantic-liskov-t0hgf?file=/src/index.js:323-422
Thank you
Posted 12 January 2022, 5:33 pm EST
Hi,
You can wrap the value when user presses Alt+Enter while editing cell by binding the sheet with ValueChangedEvent and enabling the wordWrap to true and apply autofit on the row if the new value contains the new line character(“\n”).
Please refer to the sample and let us know if you face any further issues: https://jscodemine.grapecity.com/share/Xl-10FG1Y0Gksojp6HlRTw/
Value Changed Event: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Events~ValueChanged_EV.html
WordWrap: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.CellRange~wordWrap.html
AutoFitRow:https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~autoFitRow.html
Regards