Free Support Forum - aspose.com

Setting Table Style

Hi Aspose Team -

I want to define and use a table style as I build a dynamic table through the builder. I can do this with paragraph formats. I can define the paragraph format and save it in the document object, and assign it with builder.ParagraphFormat.Style. But I don't see how to do this for a table style. Am I missing something obvious?

thanks - bk

Hello

Thanks for your request. Unfortunately, currently there is no way to set table style in Aspose.Words. Your request has been linked to the appropriate issue. We will let you know once this is supported.

Best regards,

Thanks for the reply.

I do have a semi-related question. I am generating dynamic tables within an aspose object just fine. When I save it to a Word document, it looks fine. When I print the Word document from Word, it looks fine. However, when I print the aspose object, the printer adds additional blank rows between the tables. I have read that this might be due to Word 2007. I suspect I am not setting some properties to prevent this. So I have been playing with the following properties...

builder.ParagraphFormat.NoSpaceBetweenParagraphsOfSameStyle = True

builder.ParagraphFormat.SpaceBeforeAuto = False

builder.ParagraphFormat.SpaceAfterAuto = False

builder.ParagraphFormat.SpaceBefore = 0

builder.ParagraphFormat.SpaceAfter = 0

So far nothing works.

Have you heard of this printer effect with aspose document objects that contain multiple tables?

Thanks - I appreciate any help - I'm starting to run out of ideas.

bk


Hello,
Thank you for your request.
Could you please provide us a small test application that would have been able to simulate the problem.

Hello Bob,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. It seems your problem was fixed in the latest release of Aspose.Words. Please try using the latest version of Aspose.Words (9.7.0) and let me know how it goes on your side.

You can download the latest version here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Best regards,

Thanks Andre

I was hoping this might be fixed in a more recent version. I seem to have found a temporary workaround. I'm curious what you think of this bit of information. I save my AsposeDocObject, which consists of several dynamically built tables and when printed displays extra rows between those tables, to a .doc file. I then load that file back into an AsposeDocObject. This time the AsposeDocObject prints correctly.

However, when I save my AsposeDocObject to a .docx file and load it back into an AsposeDocObject, the extra rows are displayed again.

Were there some properties not being set by Aspose? Were these properties removed when saved to the older .doc format? Will I have to worry about setting these properties in the new aspose version, or will the default behavior be to suppress the extra rows.

Thanks for your feedback - bk

Hi Bob,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. You can try using the following code to work this problem around:

Document doc = new Document("yourDoc.doc");

// Get collection of tables

NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);

// Loop through all tables

foreach (Table table in tables)

{

// Check if the next node after the tabel is another table.

if (table.NextSibling != null && table.NextSibling.NodeType == NodeType.Table)

{

Table nextTable = (Table)table.NextSibling;

// Append all rows form the current table to the next.

while (table.HasChildNodes)

nextTable.Rows.Insert(0, table.LastRow);

}

}

doc.Save("C:\\Temp\\out.pdf");

Best regards,

Thanks Andrey - I like how tight your code block is, but I need to keep my tables separate. I think my solution will work short-term. Once this release is out the door, I'll pull in the latest version and see what happens. I appreciate your help.

bk

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I can suggest you one more workaround of this issue for now:

You can insert an empty paragraph between tables. Please see the following code:

// Open document.

Document doc = new Document("in.doc");

// Get collection of tables

NodeCollection tables = doc.GetChildNodes(NodeType.Table, true);

Paragraph spliter = new Paragraph(doc);

spliter.ParagraphBreakFont.Size = 1;

// Loop through all tables

foreach (Table table in tables)

{

// Check if the next node after the tabel is another table.

// If so, insert an empty paragraph between tables.

if (table.NextSibling != null && table.NextSibling.NodeType == NodeType.Table)

table.ParentNode.InsertAfter(spliter.Clone(true), table);

}

// Save output document

doc.Save("out.pdf");

Best regards,

Thanks Andrey. I'll give that a try.

bk

The issues you have found earlier (filed as WORDSNET-581) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(90)