We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Document is not displaying properly in 2003 word

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

We have designed an application which will generate a report in word document using Aspose.word.

We are saving the document as “finalDocument.Save(_mcsStatusReportOutput,SaveFormat.Doc);”

When we open the document where 2007/2010 word is installed it is displaying properly I mean the format what we diesgned looks good and displying properly. But when we open the same document where 2003 is installed the format got corrupted and it is not displying properly. I have attached the word document which we created and also plseas see the attachments which contains the snapshot of 2003 word where it is not displaying properly. Following is the sample of code to create a cell in table (just for refernce)

private void CreateCell(string cellText, double widthOfCell, string alignType,bool isFirstColumn, bool isLastColumn)

{

builder.InsertCell();

builder.InsertHtml(cellText);

builder.CellFormat.HorizontalMerge = CellMerge.None;

if (alignType.Equals("left", StringComparison.InvariantCultureIgnoreCase))

{

builder.ParagraphFormat.Alignment = ParagraphAlignment.Left;

}

else if (alignType.Equals("right", StringComparison.InvariantCultureIgnoreCase))

{

builder.ParagraphFormat.Alignment = ParagraphAlignment.Right;

}

else if (alignType.Equals("center", StringComparison.InvariantCultureIgnoreCase))

{

builder.ParagraphFormat.Alignment = ParagraphAlignment.Center;

}

else

{

builder.ParagraphFormat.Alignment = ParagraphAlignment.Justify;

}

builder.CellFormat.VerticalMerge = CellMerge.None;

builder.CellFormat.Width = widthOfCell;

}

One more point is when we open the document in 2003 office the format will be correupted and if we double click in one of the cell inside the table the format is restroing/displying properly. For this when we recorded the macro to know what code it is genrating , it got the following:

Sub Macro2()

Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(2.56), _

Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces

End Sub

Please help me in regarding this.

For word 2003 we need to code something differently? Or any format issue with 2003?

Hi

Thanks for your request. As I can see, you are using quite old (9.1.0) version of Aspose.Words. Have you tried using the latest version? You can download it from here:

http://www.aspose.com/community/files/51/.net-components/aspose.words-for-.net/category1188.aspx

Also, it would be great if you provide a sample code that we can use to generate such document. We will check the issue and provide you more information.

Best regards,

hi,

actually now i got it. the problem identified is I have created a table with 9 columns and for some of the rows i inserted data into one cell and merged remaing cells into one. this is properly displaying in 2007/2010 but the same thing is not displaying in 2003.

private void PerformColumnMerge(int numberOfCellsToBeMerged, double widthOfEachCell)

{

// Merging all the cells

for (int count = 0; count < numberOfCellsToBeMerged; count++)

{

builder.InsertCell();

builder.CellFormat.Borders.Left.LineStyle = LineStyle.None;

builder.CellFormat.Width = widthOfEachCell;

builder.CellFormat.HorizontalMerge = CellMerge.Previous;

}

}

now i commented above method and instead of doing merge im creating one cell with width of 9 cells. this way it is displaying properly. but my question is cell.merge is not working properl;y in 2003 ? please clarify regarding this

Hi

Thanks for your request. 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 scenarios should work properly in all versions of MS Word. By the way there were few fixes regarding horizontally merged cells in DOC format. So I would suggest you to try using the latest version of Aspose.Words. This might resolve your original problem.

Best regards,