Apose Excel data replacing in Word

Hello Team, Here I am Replacing Excel sheet data into word document using Aspose.word and Cell, After replacing those data, it’s not aligned. I need support while replacing excel data into Word data should format according to word. Here I attached to code sample and input and output data.
Code-Samples.zip (348.7 KB)

@bkalightaspose1125 Unfortunately, the provided code is not complete. ReplacingWithFormatting is not provided. Could you please create a simple console application that will allow us to reproduce the problem and attach it here? Also, please provide the expected output you would like to get.

@alexey.noskov Please find the attached code
Excel_doc_console.zip (507.0 KB)

@bkalightaspose1125 I am afraid, there is no easy solution for the problem. You can using HTML as an intermediate format to transfer data from Excel to Word. You should note, that HTML is not native format neither for Excel nor for Word. Aspose.Words Document Object Model is designed to work with MS Word documents. HTML documents object model is quite different and it is not always possible to provide 100% fidelity after importing or exporting HTML document. Usually Aspose.Words mimics MS Word behavior when work with HTML documents.

Partially, the problem can be resolved by fitting the table to window:

foreach (Table t in wordDoc.GetChildNodes(NodeType.Table, true))
{
    t.AutoFit(AutoFitBehavior.AutoFitToWindow);
}

Here is the produced output: out.docx (139.9 KB)

Some tables looks better, but still there are issues in the document.

1 Like