Aspose Word version Issue with table

Dear Admin,

I’m using the old version of Aspose library, which is 23.5.0. However, I was unable to export a horizontal table.

-------------------------------------
|<<foreach [data in Data] -horz>>    |
|<</foreach>>                        |
-------------------------------------

I’m getting error message

System.InvalidOperationException: ‘Tag ‘foreach’ is not well-formed. Character ‘-’ is unexpected.’

Please advise, that any other method to generate the table.

@leoteoh

It seems that you are encountering an issue with the foreach tag in your Aspose.Words implementation, specifically with the syntax used for generating a horizontal table. The error message indicates that the tag is not well-formed due to the unexpected character ‘-’.

To resolve this issue, you can try the following approaches:

  1. Correct the Syntax: Ensure that the syntax for the foreach tag is correctly formatted. The correct format should not include any unexpected characters. For example, you might want to use:

    <<foreach [data in Data]>>
    
  2. Use DocumentBuilder: If you are looking for an alternative method to generate tables, consider using the DocumentBuilder class. This class provides a straightforward way to create and manipulate tables programmatically. Here’s a simple example of how to create a table using DocumentBuilder:

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);
    
    // Start the table
    builder.StartTable();
    
    // Insert cells
    builder.InsertCell();
    builder.Write("Cell 1");
    builder.InsertCell();
    builder.Write("Cell 2");
    builder.EndRow();
    
    builder.InsertCell();
    builder.Write("Cell 3");
    builder.InsertCell();
    builder.Write("Cell 4");
    builder.EndRow();
    
    // End the table
    builder.EndTable();
    
    // Save the document
    doc.Save("TableExample.docx");
    
  3. Check for Updates: Since you are using an older version of the Aspose library (23.5.0), consider updating to the latest version. Newer versions may have improvements and bug fixes that could resolve your issue.

If you continue to experience problems, please provide more details about your implementation, and I would be happy to assist further!

Thanks for the reply. Kindly refer to this thread Issues with Pivot Table In Word Document - Free Support Forum - aspose.com

It works very well with the latest version of the library, but when I revert to the version 23.5.0 due to licensing, the

-horz

not working well.

@leoteoh This feature (WORDSNET-18034) has been introduced in 23.6 version of Aspose.Words.

Hi, thanks for the reply. If I’m using 23.5, what can I do to replace

-horz

to generate the similar table?

@leoteoh I am afraid there is no analog of -horz in Aspose.Words prior 23.6 version. So I would suggest you to update to the latest version.

1 Like