DOCXReadWrite accessing tables data

Questions and answers on how to use DOCXReadWrite
Post Reply
eteoklis
Posts: 31
Joined: Wed Feb 03, 2021 10:42 am

DOCXReadWrite accessing tables data

Post by eteoklis »

Hello

When we alter a text inside a cell in table with plaintext command the formatting of the cell is lost.

Is it possible to have direct access in the text contents of a cell in a table and make changes on it without loosing the formatting of the cell?

e.g.
// Get the cell.
Cell := DOCX.Editor.Paras.Tables[0].Rows[1].Cells[2];
// Replace the text.
Cell.Paras.PlainText := 'Lorem ipsum dolor sit amet'; <-----

Also it would be nice to be able to insert table rows and not always append a new one.

Thanks in advance
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: DOCXReadWrite accessing tables data

Post by larsa »

Hello

There is a InsertRow method in the Table object.

What kind of formatting is it that is lost?
Lars Arvidsson, Axolot Data
eteoklis
Posts: 31
Joined: Wed Feb 03, 2021 10:42 am

Re: DOCXReadWrite accessing tables data

Post by eteoklis »

Hello

for example
We use one template with more than one tables and different format in some cells (font size, bold, italic, font color)

We want to replace formatted text (Arial,Bold, Italic, fontColor=Blue) in a cell with one string with LF (like your sample) and to keep the original cell format (Arial,Bold, Italic, fontColor=Blue)

If we use cell.paras.plainText:= ‘line1’+#13+’line2’+#13+’line3’ we take the correct string but we lose the formatting and the LF

If we use cell.paras.FileText := ‘line1’+#13+’line2’+#13+’line3’ we take the correct string, with LF but we lose all the formatting

When we tried with “find and replace” we get the correct string, the correct formatting but we lost LF.

Is there any way to keep the original cell text formatting, or to reset it back to the original after “filetext” call?

The best would be to have direct access to the text of a table without loosing any formatting.

Thanks in advance
Post Reply