Similar functionality to the Selection.EndKey Method (Word) in Aspose

Good Morning,

Could anyone help me on this. What can be the method used similar to the Selection.EndKey Method (Word) in aspose.words for Java.

And also please suggest me on this too what can be the similar functionality can be used for Selection.Delete Method (Word) in Aspose

Any help is truly appreciated

Thanks
Uday Baba

Hi Uday,

Thanks for your inquiry. Aspose.Words is a class library that enables your applications to perform a great range of document processing tasks. Aspose.Words supports DOC, DOCX, RTF, HTML, OpenDocument, PDF, XPS, EPUB and other formats. With Aspose.Words you can generate, modify, convert, render and print documents without utilizing Microsoft Word®. Please check Aspose.Words for Java - API Reference.

There are no similar methods of Selection.EndKey and Selection.EndKey in Aspose.Words. However, you can modify the contents of Word document, move the cursor to any location in the document and insert new contents. You can also remove text, images, tables etc. from document. We suggest you please read following articles for your kind reference.

Object Model Overview
Use DocumentBuilder to Insert Document Elements
Using DocumentBuilder to Modify a Document

Please share your input and expected output documents here for our reference. We will then share the code example according to your requirements.

Thanks you,

I’ve another question which I enclosed in the attached document along with inputs and expected output and what output I’m getting.

Could you please help me on this too.

Thanks
Uday Baba

Hi Uday,

Thanks for your inquiry. The second row have only one wide cell. In your case we suggest you following solution.

  1. Split the second row’s cell into five cells and remove their border.
  2. Move the cursor to the bookmark e.g. bookmark1 and get the Row node using Node.GetAncestor method
  3. Move the cursor to each cell of row and insert contents using DocumentBuilder.Write method.

We have attached sample input document for your kind reference with this post. Please check following code example. Hope this helps you.

Regarding formatting issue, the paragraphs in the last row of table have font name ‘Times New Roman’. You are getting correct output. Please set font’s formatting of text according to your requirement in your input document. E.g. in last row of table. Please move the cursor to the desired location and insert the contents using DocumentBuilder.Write method.

Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToBookmark("bookmark1");
Row row = (Row)builder.CurrentParagraph.GetAncestor(NodeType.Row);
builder.MoveTo(row.Cells[0].FirstParagraph);
builder.Write("text 1");
builder.MoveTo(row.Cells[1].FirstParagraph);
builder.Write("text 2");
builder.MoveTo(row.Cells[2].FirstParagraph);
builder.Write("text 3");
builder.MoveTo(row.Cells[3].FirstParagraph);
builder.Write("text 4");
builder.MoveTo(row.Cells[4].FirstParagraph);
builder.Write("text 5");
doc.Save(MyDir + "Out v16.6.0.docx");