Table style gets lost

Dear Aspose team!

I got the following problem:

  • I create a Word file by the Word-application

  • 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 a lot for your help,

cheers,

Stephan

Hi

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.

Best regards.

Hi Alexey!

Thank you for your immediate reply.

Unfortunately this issue is very urgent for us.

Is there a workaround?

Thank you and cheers,

Stephan

Hi Stephan,

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

Best regards.

To avoid misunderstandings:

It is not our intention, to create or to manipulate table styles with Aspose;

we just want to insert table data with keeping the original style of the table.

We are quite sure that this worked with older Aspose.Words versions.

Thanks,

Stephan

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.

Best regards.

Hi Alexey!

Please find attached two files:

  1. Table_before_and_after_data_insertion.pdf

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.

  1. 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.

Thanks,

Stephan

Hi

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.

Best regards.

Hi Alexey!

Thank you for your response and for the error logging.

Yes, you are right; the table header “bold” formatting is a further problem but a minor one.

The major problem (with the style) remains:

Can you imagine why we managed to keep the table style with Aspose.Words 6.2 while 6.4 is not able to process table styles?

Thanks for your efforts,

cheers,

Stephan

Hi

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?

Best regards.

Hi Alexey!

Yes, of course.

Please find attached

  1. the source document with empty table but special table style

Table_with_style_but_without_any_data.docx

  1. the document with the filled table but lost style

Table_filled_with_data_but_style_got_lost.docx

The data has been filled with Aspose 6.4

Thanks a lot,

cheers,

Stephan

Hi Alexey!

Sorry for the delay - you’re waiting for further information like code etc.

  1. the expected result would be a table filled with data and with the style set in the original table

  2. 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.

Best regards.

Hi Alexey!

Thanks for your quick help.

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.

Could you tell me when this issue will be fixed?

Thank you,

Stephan

Hi

Thanks for your request. Unfortunately, I cannot provide you any reliable estimate regarding this issue at the moment.

Best regards.

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 7100) have been fixed in this update.


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

The issues you have found earlier (filed as 5262;9200) have been fixed in this update.


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

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