We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Select range of cells

Hi,

In Aspose word, I need to select range of cells in the table- so that I can delete the text, copy the text or paste the text.

I want to select all the cells from row 1 cell 3 to row 4 cell 5.

Please advise.

Hi there,


Thanks for your inquiry. We suggest you please read about Aspose.Words document object model from here:
Aspose.Words Document Object Model

All text of the document is stored in runs of text. The Cell class represents a table cell. The text inside table’s cell is in Run nodes. Please use the Run.Text property to get or set the text of Run node. Please refer to the following article and let us know if you have any more queries.
Working with Tables

Didn’t answer my question.


I want to select range of cells in table.
Below code shows applying style to one cell.
I want to do the same for the range of cells.
e.g from Row 2 Cell 3 TO Row 4 Cell5

<table class=“highlight tab-size js-file-line-container” data-tab-size=“8” style=“color: rgb(51, 51, 51); padding: 0px; margin: 0px; font-family: SFMono-Regular, Consolas, “Liberation Mono”, Menlo, Courier, monospace; font-size: 12px; line-height: 1.4; background: rgb(255, 255, 255); border: 0px; border-collapse: collapse;”>e.g, below shows applying style to one cell.
Document doc = new Document(dataDir + “Table.Document.doc”);
Table table = (Table)doc.GetChild(NodeType.Table, 0, true);
Cell firstCell = table.FirstRow.FirstCell;
firstCell.CellFormat.Width = 30; // In points
Hi there,

Thanks for your inquiry. Unfortunately, there is no API to select range of cells. However, you can achieve your requirement using Aspose.Words. Row.Cells property returns the collection of cells in a row. Please use the Cell.CellFormat property for the formatting of a cell.

Please refer to the following article:
Applying Formatting on the Cell Level

Following code snippet shows how to get the third cell of second row of table. Please use the same approach to get the desired cells of a row.

Document doc = new Document(dataDir + "Table.Document.doc");

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

//Get the third cell of second row.

Cell cell = table.Rows[1].Cells[2];

cell.CellFormat.Width = 30; // In points