after inserting an empty table (also by Word application), I set a table style for the table (e.g. Medium Grid 3 - Accent 3)
then I create an Aspose.Words Document instance and fill the empty table cells with data by the Aspose.Words API
by saving the modified document, the table style set before gets lost; just the table data remains (even without any lines of the grid)
Do you know why the style gets lost?
How can I check (when debugging), which style is set for a table? Although I found the docs of the Style class and descriptions, how to add a style to a document, I do not know how to map a style to a special table.
just describes how to format paragraphs, doesn’t it?
Thanks for your request. Currently, Aspose.Words does not support table styles. This is the issue #5262 in our defect database. I will notify you as soon as this feature is supported. But I cannot promise you a fast fix of this issue.
Thanks for your inquiry. The only workaround of the problem - do not use table styles. You can directly set formatting of paragraphs, cells and rows in your table
Stephan, please attach sample documents here. I will check it on my side and provide you more information. I do not think that this could work in some old versions.
This file contains screenshots of the word table before and after inserting the data by the Aspose.Words-API (Version 6.2). As you can see, the original table style remains.
Table_before_data_insertion.doc
This is the original Word document with the table before the data insertion. Please note that this file contains a customization assembly and will probably cause an error pop-up when you open it.
Currently, it is not that easy to provide the result table as Word file because it is created in a batch process which converts it to pdf.
As soon as I receive this result DOC-file, I’ll post it here, too.
Please try to find out what could be the cause of our problems.
Thank you for additional information. I see that bold text in the table header becomes regular after open/save the document using Aspose.Words. I logged this problem in our defect database as issue #9200. I will notify you as soon as it is fixed.
As a workaround, you can open your template in Ms Word and save with different name. After such roundtrip formating of text will not be changed after open/save the document using Aspose.Words.
Thank for your inquiry, but I cannot see any changes in table formatting after processing your document using Aspose.Words 6.4.0. Could you please create sample code that will demonstrate the problem and attach your output and expected output documents here?
Sorry for the delay - you’re waiting for further information like code etc.
the expected result would be a table filled with data and with the style set in the original table
some code:
foreach (Cell c in table)
{
//under special conditions, do some formattings
if (c.Paragraphs[0].Runs[0] != null)
{
c.Paragraphs[0].Runs[0].Text = cellData;
}
else
{
Run newRun = new Run(wordTable.Document, cellData);
c.Paragraphs[0].AppendChild(newRun);
}
}
Thank you for additional information. The problem occurs because in first case you have used DOC file as a template and in the second case you have used DOCX. This problem is logged in our defect database as issue #7100.
As a workaround, you can open your DOCX template in MS Word and save it in DOC format, and use DOC file as a template in your application.
Unfortunately, your suggested workaround won’t be suitable for us because our solution must be full Word 2007 compatible. So we have to keep the DOCX format.
What I tried was editing the docx’s XML file by reinserting the lost table style tag. Although this caused no error, it did not work: the style was still lost.
Ok, I looked through the code and here is what I can tell:
Table styles in DOC are “just barely supported”. It means Aspose.Words reads the binary definition of the style into memory and writes it without changes to the output DOC file. Writing to any other file format will not write or use the table style information in any way. So I can confirm that in your case opening DOC with a table style, inserting some data and saving as DOC - it really works. The table style stays put.
However, table styles are not preserved when working with DOCX. Aspose.Words does read a table style, but it just “flattens” it e.g. applies all formatting it can to the table (cannot do alternating row colors etc for example).
If you are interested in just preserving table styles in DOCX-to-DOCX in the same way as this currently works for DOC-to-DOC then we can probably do that as a quick fix.
Please confirm that you are not interested in conversion to PDF or anything else because that will be a completely different scale of work.
This is exactly what we need for the moment. We just need the same processing of table styles as in DOC.
“If you are interested in just preserving table styles in DOCX-to-DOCX in the same way as this currently works for DOC-to-DOC then we can probably do that as a quick fix.” - yes that’s what we want to do.
We do not want to alter the styles with ASPOSE.Words we just only want to preserve the table styles from the original document.
For the moment we are not interested or intended in a PDF conversion or something like that. It is only a DOCX-DOCX roundtrip. But PDF conversion might be an option in the future because you offer such a automated conversion with ASPOSE.Words.
The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan