Free Support Forum - aspose.com

Cell handling in tables

Is the following a bug in Aspose or is there another explanation for this behaviour in aspose?

While looking at a table (the attached tabellertestdok.docx) in documentexplorer your can see the count of cellitems. Visually you can see them in the attached documentexplorer.gif.

row 1 has 3 cells
row 2 has 6 cells
row 3 has 5 cells
row 4 has 5 cells
row 5 has 6 cells

If I use the following code to save the file in html and look at the cells:

//loop through every table, every row and every cell
MemoryStream htmlStream = new MemoryStream();
//doc.SaveOptions.HtmlExportImagesFolder = Path.GetTempPath();
doc.SaveOptions.HtmlExportImagesFolder = billedpath;

//Specify HtmlExportImageSaving event
doc.SaveOptions.HtmlExportImageSaving += new ExportImageSavingEventHandler(SaveOptions_HtmlExportImageSaving);
doc.Save(htmlStream, SaveFormat.Html);

XmlDocument xmlDoc2 = new XmlDocument();
htmlStream.Position = 0;
xmlDoc2.Load(htmlStream);

The result is the following:

row 1 has 3 cells
row 2 has 5 cells
row 3 has 4 cells
row 4 has 3 cells
row 5 has 6 cells

We use aspose to transform word files into custom xml files and with this behaviour in the Document class it makes it difficult to work with.

Regards

tero

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Aspose.Words retorts correct number of cells in each row. By Microsoft Word design rows in a table in a Microsoft Word document are completely independent. It means each row can have any number of cells of any width. So if you imagine first row with one wide cell and second row with two narrow cells, then looking at this document the cell in the first row will appear horizontally merged. But it is not a merged cell; it is just a single wide cell. Another perfectly valid scenario is when the first row has two cells. First cell has CellMerge.First and second cell has CellMerge.Previous, in this case, it is a merged cell. In both cases, the visual appearance in MS Word is exactly the same. Both cases are valid.

Best regards.

hi Alexey!

ok and thanks for the answer - can you help me with the following. Iif we take the example that I came with. How would the other similar solution look like (as aspose sees it but in valid html) to the example belove. The table is the same as in the attached file but filtered.

regards tero








previous






previous
















1

2

Højrestillet tekst

2

3

4

5

6

3

Midtstillet tekst

4

5

Sorry - this table. I had some crap text "previous" in the earlier one.
































1

2

Højrestillet tekst

2

3

4

5

6

3

Midtstillet tekst

4

5

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for inquiry. I converted your document to HTML on my side and as I can see the output HTML looks properly. Could you please provide me more information about the problem? It is not quite clear for me what the problem is.

Best regards,

thanks Alexey for all your answers. I found a way to calculate cells with CellMerge.Previous so it can be used with cals tables.

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

It is perfect that you found a solution of your problem. Please feel free to ask in case of any issues, I will be glad to help you.

Best regards,