How to convert table cell into HTML using C#

Hi am developing a C#.net application. I have a multiple word document upload feature and am using a telerik control to perform this action.

The uploaded wod document content has to be verified before it get uploaded and am using Aspose.words to perform this action.

Am crosschecking each cells and and if its finds good i need to save some word cells data to database and that too as html code

How can i convert a word cells data as HTML.

Please help me .

Thanks In Advance

Hi Rajeev,

Thanks for your query. It would be great if you please share some more information about Words cell data. Do you want to convert a table’s cell to HTML? Please also share your document for investigation purposes.

Hi Tahir,

Thanks for the reply. The requirement is to convert the data in a particular word cell to html(we dont require the whole word document to be converted , only one or two word cells data is needed to be saved as html code

Could you pls help me

Hi Rajeev,

Thanks for sharing the information. Please use the following code snippet to convert a specific table’s cell to html. Please let us know if you have any more queries.

// Get table’s cell from in.docx

Document doc = new Document(MyDir + "in.docx");

Table table = (Table)doc.GetChild(NodeType.Table, 0, true);

// Get first cell from a table

Cell cell = table.Rows[0].Cells[0];

// Create and empty Ddcument, we will use it as a container for cell's content.

Document tempDoc = new Document();

// There is one empty paragraph in the newly created document. Remove it.

tempDoc.FirstSection.Body.RemoveAllChildren();

// Create NodeImporter, we will use it to copy content from the cell to the temporary document.

NodeImporter importer = new NodeImporter(cell.Document, tempDoc, ImportFormatMode.KeepSourceFormatting);

// Copy content from cell into a temporary document.

foreach (Node node in cell.ChildNodes)

{

Node importedNode = importer.ImportNode(node, true);

tempDoc.FirstSection.Body.AppendChild(importedNode);

}

tempDoc.Save(MyDir + "AsposeOut.html");

Thanks Tahir for your help. Will try this code and get back to u ASAP

Thanks Once Again :)

Hi
Rajeev,


Sure, we will wait for your input. Please let us know any time you have any further queries. We are always glad to help you.

Best Regards,