Get table or cell formatting

Apr 22, 2011 at 2:00 PM

I have a table in a document that I am trying to append rows to.  When I add the new rows, the text in the rows doesn't match the font family and font size of the existing rows.  Is there a way to get the font and size of the existing rows and apply that to the new rows to append?

Coordinator
Apr 22, 2011 at 2:20 PM

This is tricky because font and size are applied at the run level.

A row can contain many cells which can each contain many paragraphs which can each contain many runs.

This is why new rows have no text formatting when they are first added.

Can you think of a good why to impliment what you want?

On 22 Apr 2011 15:00, "gmhamm0" <notifications@codeplex.com> wrote:
> From: gmhamm0
>
> I have a table in a document that I am trying to append rows to. When I add the new rows, the text in the rows doesn't match the font family and font size of the existing rows. Is there a way to get the font and size of the existing rows and apply that to the new rows to append?
>
>
Coordinator
Apr 22, 2011 at 2:28 PM

I am hesitant about adding List<Run> runs = Paragraphs.runs to DocX because DocX is suppose to hide the awful internal structure of documents from the user.

I would prefer to add Paragraph.styles which returns a Dictionary<int, Formatting> the int's being the character index that the Formatting is applied from and the Formatting object being the same as the one used for insert and replace text.

How do people feel about this?

On 22 Apr 2011 15:20, "cathal coffey" <coffey.cathal@gmail.com> wrote:
> This is tricky because font and size are applied at the run level.
>
> A row can contain many cells which can each contain many paragraphs which
> can each contain many runs.
>
> This is why new rows have no text formatting when they are first added.
>
> Can you think of a good why to impliment what you want?
> On 22 Apr 2011 15:00, "gmhamm0" <notifications@codeplex.com> wrote:
>> From: gmhamm0
>>
>> I have a table in a document that I am trying to append rows to. When I
> add the new rows, the text in the rows doesn't match the font family and
> font size of the existing rows. Is there a way to get the font and size of
> the existing rows and apply that to the new rows to append?
>>
>>
Apr 22, 2011 at 2:29 PM
Edited Apr 22, 2011 at 2:31 PM

For my project, we are loading templates that make use of multiple tables. These tables kind of serve as place holders. Each table contains a a row with header info for each column. I then need to populate these tables with the appropriate data. The goal is to control the formatting of the table through the formatting of the header row. Any number of users can create these templates so that they can customize them however they want. You make a good point below and I see how this could be difficult. However, in my case i really only need the font family and font size of the paragraph. Each cell will only contain one paragraph, so if I could just get these properties from paragraph 0 in each cell, then I would have what I need.

________________________________

From: coffeycathal [mailto:[email removed]
Sent: Fri 4/22/2011 10:20 AM
To: Hammond, Greg
Subject: Re: Get table or cell formatting [DocX:254941]



From: coffeycathal

This is tricky because font and size are applied at the run level.

A row can contain many cells which can each contain many paragraphs which can each contain many runs.

This is why new rows have no text formatting when they are first added.

Can you think of a good why to impliment what you want?

On 22 Apr 2011 15:00, "gmhamm0" <[email removed]> wrote:
> From: gmhamm0
>
> I have a table in a document that I am trying to append rows to. When I add the new rows, the text in the rows doesn't match the font family and font size of the existing rows. Is there a way to get the font and size of the existing rows and apply that to the new rows to append?
>
>


Read the full discussion online <http://docx.codeplex.com/discussions/254941#post601527> .

To add a post to this discussion, reply to this email ([email removed] <mailto:[email removed]?subject=[DocX:254941]> )

To start a new discussion for this project, email [email removed]

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe <https://docx.codeplex.com/discussions/254941/unsubscribe/> on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com

May 6, 2011 at 3:02 AM

 

Not to stir up an old thread, but has there been any progress on this? 

My situation is very similar to Greg's.  We're loading in a document containing a number of different tables as templates into memory, adding / rearranging rows, and spitting it out into a new document.  These paragraphs lose all their attributes in the process, and setting the formatting programmatically isn't practical.

We're not really sure where to turn from here for long-term maintainability.

 

Any ideas are greatly appreciated!

 

Regards,

Chris