Issues related to wrap the text programmatically

I am using aspose cells for grid js . Is there any way to wrap the text programmatically.

image.png (91.5 KB)

@sarathepiq

To wrap text programmatically, you can use various methods depending on the programming language or framework you are working with. Below are some common approaches in different contexts:

1. HTML/CSS

If you are working with HTML and CSS, you can wrap text using CSS properties. For example:

<div style="width: 200px; word-wrap: break-word;">
    This is a long text that will wrap within the specified width of the div.
</div>

2. JavaScript

If you want to manipulate text wrapping dynamically using JavaScript, you can set the CSS properties programmatically:

const element = document.getElementById('myElement');
element.style.width = '200px';
element.style.wordWrap = 'break-word';
element.innerText = 'This is a long text that will wrap within the specified width of the div.';

3. Python (e.g., in a GUI application)

If you are using a GUI framework like Tkinter, you can wrap text in a Label or Text widget:

import tkinter as tk

root = tk.Tk()
label = tk.Label(root, text="This is a long text that will wrap within the specified width of the label.", wraplength=200)
label.pack()
root.mainloop()

4. Using a Text Editor Library

If you are working with a text editor library (like Quill, Draft.js, etc.), they usually have built-in support for text wrapping. You can configure the editor settings to enable text wrapping.

5. In a Word Processor (e.g., using Python-docx)

If you are generating documents programmatically, you can use libraries like python-docx to wrap text in Word documents:

from docx import Document

doc = Document()
doc.add_paragraph("This is a long text that will wrap within the specified width of the document.")
doc.save('wrapped_text.docx')

Conclusion

The method you choose will depend on the context in which you are working. If you provide more details about the environment or framework you are using, I can give you a more tailored solution.

@sarathepiq
You can use

const iswrap=true;
 xs.sheet.data.setRangeAttr({sri:4,sci:9,eri:4,eci:9},"textwrap",iswrap)

you can search the “wrap” keyword in the below document :

Is aspose handle the textwrap automatically , while modifying the cell content.

@sarathepiq
basically,the textwrap is specified by the style info of the cell .
the document is here.

If you mean the height?
when enter new line by “alt+enter” key or click the text wrap in the toolbar,
the height will be adjusted automatically.

f8eeed27-e5f9-4fa9-8747-3f9aed065245.png (18.2 KB)

I am using “gridjs-spreadsheet”: “^24.6.2” version , while using the below method I got error setRangeAttr is not a functoin , I neeed to use this in 24.6.2 version .
In the 25.9 version this function is working fine.

const iswrap=true;
xs.sheet.data.setRangeAttr({sri:4,sci:9,eri:4,eci:9},“textwrap”,iswrap)

@sarathepiq
yes,those APIs are newly added,please always update to the latest version.

@sarathepiq
You prefer to use the old version.
Tell us if you meet any inconvenience or issues when you update to the latest version.
we will always help you .

Can we use below code snippet to wrap the text in “gridjs-spreadsheet”: “^24.6.2”
xs.sheet.data.setSelectedCellAttr(“textwrap”, true);

In the latest version of Aspose.Cells.GridJs, images are not loading as expected. To address this, we created a separate support ticket and implemented customizations in a lower version where the issue does not occur. We plan to upgrade to version 25 later, once the image loading issue is resolved .

@sarathepiq

xs.sheet.data.setSelectedCellAttr('textwrap', true); 

only applies to the currently selected cell area.

@sarathepiq
We still cannot reproduce the image load issues in the latest v25.9 version. Can you provide more info for this issue. For example, open the develop console of the browser, track the networks connections for the images loading.


or can you provide a sample project to reproduce the issue.

hi Peter, Our current version is 24.6.2, we are planning to upgrade with your upcoming V25.10. Will evaluate this once after that.

@purushothamj
We will release 25.10 in the first half of October.
Please wait patiently.