Free Support Forum - aspose.com

HTML to DOCX conversion throws InvalidOperationException using C#

Hi, I am facing an issue when converting Html to Word (docx) documents using Aspose.Words nuget package version (19.11.0) in .Net application and seeing this error message:

More than 63 cells per row is not supported for this file format

I understand that more than 63 cells are a limitation but I could not identify 63+ cells in a table in the sample document I have attached for your reference.

I am using the following code to convert document(s):

        var htmlLoadOptions = new HtmlLoadOptions();
        htmlLoadOptions.PreferredControlType = HtmlControlType.StructuredDocumentTag;

        // Setting the Enconding
        htmlLoadOptions.Encoding = Encoding.UTF8;

        // Create a new class implementing IWarningCallback which collect any warnings produced during document save.
        var callback = new HandleDocumentWarnings();

        // We assign the callback to the appropriate save options class. In this case, we are going to save to Word
        // so we create a HtmlLoadOptions class and assign the callback there.
        htmlLoadOptions.WarningCallback = callback;

        // Load the Html document into memory
        var document = new Document(info.File, htmlLoadOptions);
        
        foreach (Table table in document.GetChildNodes(NodeType.Table, true))
        {
            foreach (Row row in table.Rows)
            {
                row.RowFormat.AllowBreakAcrossPages = false;
            }
        }

        info.File.Close();

        // Convert the document to a different format and save to stream
        var streamResult = new MemoryStream();

        var options = SaveOptions.CreateSaveOptions(SaveFormat.Docx);
        options.TempFolder = WorkingDirectory;
        document.Save(streamResult, options);

Can you please examine the data to check why this is the case as hundreds of documents are throwing the same error at conversion time?

Thanks in advance.
aspose_error_details.zip (380.2 KB)

@zallauddin

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19889 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hi @tahir.manzoor,

Any rough idea about the resolution ETA for this issue?

@zallauddin

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

A post was split to a new topic: Limitation of html table having more than 63 cell

The issues you have found earlier (filed as WORDSNET-19889) have been fixed in this Aspose.Words for .NET 20.9 update and this Aspose.Words for Java 20.9 update.