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

Free Support Forum - aspose.com

Issue related to cell color in Aspose word version 7.0.0.0

Hi AndreyN,

Thanks for your instant reply & suggestions.

We are facing one problem related to cell border color.

This issue is ocurre after shifting entire project code-base from Aspose Word version 6.2.0.0 to Aspose Word version 7.0.0.0.

We are currently using Aspose Word version 7.0.0.0.

Please refer attached image & word documents from version 6.2.0.0.0 & 7.0.0.0 for further investigation.

Stenchart_7.0.0.0.doc contain output with error.

Stenchart_6.2.0.0.0.doc conatin correct output.

Tha problem area is marked with red color in attched image.

1> We do not change single line of code while shifting entire code-base from 6.2.0.0.0 to 7.0.0.0.

2> If you can observe the word output in Aspose Word 6.2.0.0, it is working fine.

Waiting for your reply.....!!!!!!

Thanks & Regards,

Dwarika.

Hi

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

Thanks for your request. Could you please show me simple code? Please note, I do not need all your code, just a simple example which will allow me to reproduce the problem on my side.

Best regards,

Hi AndreyN,

Thank you for support & suggestion.

After doing huge amount of debugging & reasearch we come to conclusion that the above problem is related to LineStyle in Aspose Word version 7.0.0.0

If we use the LineStyle as a "Single" the white line between two cell is not appearing on report.

If we change the LineStyle as a "Thick" then the white between two cells is appearing on report.

Please refer the attached output ( in word format) with LineStyle set as "Single" & "Thick" for your further investigation.

Also refer the attached screen shot images indicating problem area in respected reports.

The sample code as per your request is as follows:

The red lines indicate the problem statement in the code.

private void button1_Click(object sender, EventArgs e)

{

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

//Initialize Aspose license.

Aspose.Words.License lic = new Aspose.Words.License();

lic.SetLicense(path + @"\Aspose.Total.lic");

Aspose.Pdf.License lic1 = new Aspose.Pdf.License();

lic1.SetLicense(path + @"\Aspose.Total.lic");

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

//set the page set-up

Aspose.Words.PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

//start drawing table

documentBuilder.StartTable();

//Set row formatting.

documentBuilder.RowFormat.Borders.Color = System.Drawing.Color.RoyalBlue;

documentBuilder.RowFormat.Borders.LineStyle = LineStyle.Single;

documentBuilder.RowFormat.Borders.LineWidth = 1.0;

//Set Cell formatting.

documentBuilder.CellFormat.Width = 100;

documentBuilder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.Navy;

documentBuilder.CellFormat.FitText = true;

//Insert first cell

documentBuilder.InsertCell();

documentBuilder.Write("HI");

//merge horizonatlly next created cell to previous cell

documentBuilder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.Previous;

//Add nect vell (this cell get merger to previous cell)

documentBuilder.InsertCell();

documentBuilder.Write(" Bye");

//create new cell.

documentBuilder.InsertCell();

//clear all previous cell formatting.

documentBuilder.CellFormat.ClearFormatting();

//Set new formatting.

documentBuilder.CellFormat.Width = 150;

documentBuilder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.Navy;

documentBuilder.CellFormat.Borders[BorderType.Left].Color = System.Drawing.Color.White;

documentBuilder.CellFormat.Borders[BorderType.Left].LineWidth = 1.0;

//Assign new LineStyle.

//documentBuilder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.Single;

documentBuilder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.Thick;

documentBuilder.Write("12345");

//End row & table.

documentBuilder.EndRow();

documentBuilder.EndTable();

//Save document.

doc.Save("sample.doc");

StartWord("sample.doc");

}

private void StartWord(string FilePath)

{

System.Diagnostics.Process pr = new System.Diagnostics.Process();

pr.StartInfo.FileName = "winword.exe";

pr.StartInfo.Arguments = FilePath;

pr.Start();

}

Will you please reply back on this issue?

1> Are you able to reproduce this issue @ your end.

2> If yes, then when we will expect a fix for this issue ?

Waiting for your reply.........!!!!

Thanks & Regards,

Dwarika

Hi AndreyN,

Adding some more points to my previous post.....!!!!!!

We have found some serious issue in word to pdf conversion.

With reference to our earlier post that we are using Aspose.Word version 7.0.0.0 & latest method

( doc.SaveToPdf("sample.pdf"); ) for converting Word document into Pdf format.

Please refer above same code for generating the output in PDF format.

Just add 1 lines for generating same document into PDF format as

doc.SaveToPdf("smaple.pdf");

Here you can easily observe that, cells are not properly merged with each other due to which it produces incorrect ouput in the PDF format.

Please refer attached PDF format document for further investigation

There LineStyle used for this code is set as "Thick".

Now there are total 2 issues you need to versify.

Issue #1:- Posted in earlier thread regarding the LineStyle as "Single" & "Thick".

Issue #2:- Cell merging issue in PDF format.

Please reply back to us on both issue as

1> Are able to reporduce both issues @ your end?

2> when will we expect a permenant fix for these both issue?

Thanks & Regards,

Dwarika.

Hi Dwarika,

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

Thank you for additional information.

1. Please try specifying left border of cell and right border of previous cell to resolve the problem. Please see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

//start drawing table

builder.StartTable();

//Set row formatting.

builder.CellFormat.Borders.Color = Color.RoyalBlue;

builder.CellFormat.Borders.LineWidth = 1.0;

//Set Cell formatting.

builder.CellFormat.Width = 100;

builder.CellFormat.Shading.BackgroundPatternColor = Color.Navy;

builder.CellFormat.FitText = true;

//Insert first cell

builder.InsertCell();

builder.CellFormat.Borders.Right.Color = Color.White;

builder.Write("test");

//create new cell.

builder.InsertCell();

builder.CellFormat.Borders.Left.Color = Color.White;

builder.CellFormat.Borders.Right.Color = Color.RoyalBlue;

builder.Write("12345");

//End row & table.

builder.EndRow();

builder.EndTable();

//Save document.

doc.Save(@"Test001\out.doc");

doc.Save(@"Test001\out.pdf");

2. First of all in your code you specified only cell merged with previous, but did not specify the first merged cell.

Also 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 you can insert simply wide cell instead of merged cells. Please see the following code:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.CellFormat.Borders.LineStyle = LineStyle.Thick;

builder.InsertCell();

builder.CellFormat.Width = 200;

builder.Write("Text in the merged cells.");

builder.EndRow();

builder.InsertCell();

builder.CellFormat.Width = 100;

builder.Write("Text in one cell.");

builder.InsertCell();

builder.CellFormat.Width = 100;

builder.Write("Text in another cell.");

builder.EndRow();

doc.Save(@"test.doc", SaveFormat.Doc);

Hope this helps.

Best regards.

Hi AndreyN,

Thank's for your quick reply & suggestion.

As per my previous post we are facing 2 issues.

So here are some updates on both the issues.

Issue no 2: Regarding cell merging problem in PDF:- we are able to resolve the previous problem .But still we found some new issues with word & PDF document.

Please refer the attched output in word & PDF format & also refer the attached image indicating the problem area.

Issue 2A:- The width of first cell is not same in word & pdf format.

Issue 2B:- For a longer text it takes 10 lines in word document but in Pdf format it is taking only 5 lines.

Issue no:-1: Still issue is not resolved.

Issue 1A:- The white-line in word document appears only when LineStyle is set as "Thick" for LineStyle set as "Single" it is not appearing as a white in report.( Pls refer attached doc named as sample_single.doc" for further investigation.)

Issue 1B:- If you can go thorugh the attached document & image carefully you can find that right border of first cell appears as white line but in its PDF version the white line is missing( refer attached doc named as "sample_thick.doc & sample_thick.pdf).

The sample code used to solve this problem is as follows. Please go through the sample code & if u find any mistake into sample code then please send corrected code to us.

Sample code:

private void button2_Click(object sender, EventArgs e)

{

string path = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

//Initialize Aspose license.

Aspose.Words.License lic = new Aspose.Words.License();

lic.SetLicense(path + @"\Aspose.Total.lic");

Aspose.Pdf.License lic1 = new Aspose.Pdf.License();

lic1.SetLicense(path + @"\Aspose.Total.lic");

Document doc = new Document();

DocumentBuilder documentBuilder = new DocumentBuilder(doc);

//set the page set-up

Aspose.Words.PageSetup pageSetup = documentBuilder.CurrentSection.PageSetup;

//start drawing table

documentBuilder.StartTable();

//Set row formatting.

documentBuilder.RowFormat.Borders.Color = System.Drawing.Color.RoyalBlue;

documentBuilder.RowFormat.Borders.LineStyle = LineStyle.Single;

documentBuilder.RowFormat.Borders.LineWidth = 1.0;

//Set Cell formatting.

documentBuilder.CellFormat.Width = 100;

documentBuilder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.Navy;

documentBuilder.CellFormat.FitText = true;

//Insert first cell

documentBuilder.InsertCell();

documentBuilder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.First;

documentBuilder.CellFormat.VerticalMerge = Aspose.Words.Tables.CellMerge.None;

documentBuilder.Write("HI");

//Add nect cell (this cell get merger to previous cell)

documentBuilder.InsertCell();

//merge horizonatlly next created cell to previous cell

documentBuilder.CellFormat.HorizontalMerge = Aspose.Words.Tables.CellMerge.Previous;

documentBuilder.Write("Bye");

//create new cell.

documentBuilder.InsertCell();

//clear all previous cell formatting.

documentBuilder.CellFormat.ClearFormatting();

//Set new formatting.

documentBuilder.CellFormat.Width = 150;

documentBuilder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.Navy;

documentBuilder.CellFormat.Borders[BorderType.Left].Color = System.Drawing.Color.White;

documentBuilder.CellFormat.Borders[BorderType.Left].LineWidth = 1.0;

//Assign new LineStyle.

//documentBuilder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.Single;

documentBuilder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.Thick;

documentBuilder.Write("12345");

//End row & table.

documentBuilder.EndRow();

documentBuilder.EndTable();

//Save document.

//doc.Save("sample.doc");

//StartWord("sample.doc");

doc.SaveToPdf("smaple.pdf");

StartPdf("smaple.pdf");

}

}

Will you please verify 1A,2A & 1B, 2B issue?

Waiting for your reply.....!!!!

Regards,

Dwarika.

Hi Dwarika,

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

Thanks for your request and additional information.

Regarding the second issue(issue with merged cells). First of all, I do not see any sense of merging cells horizontally, if there is only one row in your table. If you need a wide cell in your table, you can just specify it’s width. What is the purpose of using merged cells in your example?

Regarding the first problem (issue with border between cells). As I can see you did not tried using the workaround, I suggested. Have you at least tried to implement the same, as I suggested in my previous answer?

Best regards,

Hi AndreyN,

Thanks for your reply.

Please go through the end section of this thread for the attached file-name & their explation.

Will you please provide some more information on these issues?

1> Whether your able to reproduce all the issues @ your end?( Please specify problem wise 2A,2B,1A,1B )?

2> If yes, then when we will expect a permenant fix for these issues?

3> If you go through first post in same thread,"we already mentioned that this issue is not in Aspose word version 6.2.0.0 but in Aspose Word version 7.0.0.0."

Shall I consider this issue as compatibility issue from 6.2.0.0 to 7.0.0.0?

4>Regrading the second issue( issue with merged cells):- With refrence to my first post in same thread the origional problem related with the chart figure which is consiting of one header row & followed by multiple sub-row indicating Groups & Sub-Groups.

In order to achieve this functionality we required cell merging functionality. As per my understanding cell merging feature is an essential part of Aspose.Word & it is not restricted to no of cell's in table.

5> The code provided in previous thread is a sample code indicating the actual problem area. This sample code is as per your demand which simulates to origional code.The sample code contain the single row in table because it simulates the header row in actual chart image where the actual problem lies.

6> Regarding First issue:-Your work-around solution is welcome but still We want to know that Is there any problem in LineStyle.Single since LineStyle.Thick is Solving our problem in Word format but not in PDF format.

Pls go through attached file one by one indicating actual problem.

1>Error.PNG : - Indicating actual problem area for LineStyle.Single in Aspose Word version 7.0.0.0

2>Output_6.2.0.0.doc :- Correct output in Aspose Word version 6.2.0.0 with LineStyle As Single.

3>Output_7.0.0.0_LineStyle_Single.doc :- Problem in Aspose Word version 7.0.0.0 for LineStyle.Single.

4>Output_7.0.0.0_LineStyle_Thick.doc:- Problem Solved after code change to LineStyle.Thick in Aspose Word version 7.0.0.0

5>Output_7.0.0.0_LineStyle_thick.pdf :- Currently we are facing problem in PDF format for Aspose Word version 7.0.0.0 & LineStyle.Thick.

Problem no 5 is on highest priority for US Since it will solve our all problems.

Waiting for your reply......!!!!

Regards,

Dwarika.

Hi Dwarika,

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

Thanks for your request.

1A – Reproduced. You will be notified as soon as the problem is resolved. An easy workaround is available (see my previous answers).

1B – Reproduced.

2, 2A and 2B – Actually, I do not think that this problem should be considered as a problem in our rendering engine. Let’s consider a simple example:

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.StartTable();

builder.CellFormat.Borders.LineWidth = 1;

builder.CellFormat.Width = 100;

builder.InsertCell(); // Width of this cell is 100.

builder.CellFormat.HorizontalMerge = CellMerge.First;

builder.InsertCell(); // Width of this cell is also 100, so width of the merged cell should be 200.

builder.CellFormat.HorizontalMerge = CellMerge.Previous;

builder.EndRow();

builder.EndTable();

builder.Writeln();

// Now insert another table with only once cell with width 200 (should be the same as in previouse table)

builder.StartTable();

builder.CellFormat.Borders.LineWidth = 1;

builder.CellFormat.Width = 200;

builder.InsertCell();

builder.EndRow();

builder.EndTable();

// Now compare output PDF and DOC.

doc.Save(@"Test001\out.doc");

doc.Save(@"Test001\out.pdf");

Now, if you compare PDF and DOC files produced by this code you can see that output in PDF is closer to expected result than DOC output.

As I already mentioned earlier, in MS Word merged cells can be written as actually merged cells or as simply wide (Ms Word usually writes as simply wide cells). It seems MS Word does not like horizontally merged cells in stand-alone row, that is why width of the first table, in our case, is less than width of the second table.

On other hand, if you add one more row, your output will be expected (in both in PDF and DOC). See the following code:

// Create document and DocumentBuilder.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

builder.CellFormat.Borders.LineStyle = LineStyle.Single;

// Insert table with merged cells.

builder.CellFormat.Width = 100;

builder.InsertCell();

builder.CellFormat.HorizontalMerge = CellMerge.First;

builder.Write("This is merged cells");

builder.InsertCell();

builder.CellFormat.HorizontalMerge = CellMerge.Previous;

builder.EndRow();

builder.InsertCell();

builder.CellFormat.HorizontalMerge = CellMerge.None;

builder.InsertCell();

builder.EndRow();

builder.EndTable();

builder.Writeln();

// Insert table with simply wide cell.

builder.InsertCell();

builder.CellFormat.Width = 200;

builder.Write("This is simply wide cell");

builder.EndRow();

builder.InsertCell();

builder.CellFormat.Width = 100;

builder.InsertCell();

builder.EndRow();

builder.EndTable();

// Save output document.

doc.Save(@"Test001\out.doc");

doc.Save(@"Test001\out.pdf");

As you can see in both in PDF and DOC merged cells looks correct.

Hope this information could help you resolve the problem on your side.

Best regards,

Hi Alexey,

Thanks for your quick reply & suggestions.

With reference to your previous post 1A & 1B problems are reproduced in Aspose version 7.0.0.0

1> 1A :- Which is related to Linestyle.Single not working in Aspose Word

For this you have provided us some workaround of using LineStyle.Thick which is working fine.

2> 1B:- your work-around given in 1A is working fine for word document but the problem still remain in PDF document. This problem is also reproduced & pending from your side.

Now we are upgraded our Aspose version to 9.0.0.0 but the status of both problem are remain as it is.

Please refer the attached document for further reference.

1> 1A :- refer Sample_Single.doc

2>1B:- refer Sample_Thick.doc & Sample_Thick.pdf

Will you please confirm once when the 1B problem will get resolved.Since for 1A problem your workaround is working fine.

We are waiting for some solution or workaround from Aspose side to solve problem 1B

Thanks & Regards,

Dwarika

Hi Dwarika,

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

Thanks for your request. Unfortunately, the 1B issue still unresolved. And currently I cannot provide you any reliable estimate regarding this issue. You will be notified as soon as it is fixed.

Best regards,

Hi,

Cell borders in MS Word documents in Aspose.Words can be specified on two levels:

1. On each individual cell. You would need to use Cell.CellFormat or DocumentBuilder.CellFormat that. This is what you are using.

2. On each row. You would need to use Row.RowFormat or DocumentBuilder.RowFormat for that.

Option 1: CellFormat

If you are using CellFormat to specify cells for each cell, then you need to remember that two adjoining cells have one border in common. For example two cells adjoining horizontally will have onr common vertical border in between. It will be Right border to one cell and Left border to the other cell. To get some predictable result in the output, you need to make sure you set these borders for both cells. E.g. you should do:

myLeftCell.Borders.Right.Color = Color.Red;

myRightCell.Borders.Left.Color = Color.Red.

If you are only setting color for one of the borders - the other border remains black and in some circumstances it can "override" the red border on display. MS Word has complex rules about which border overrides which and I don't want to go into that. The best option is to make sure you set both borders to be the same to avoid such conflicts. This is the problem that you have now, fix it or see below.

Option 2: RowFormat

If you need some consistent formatting for all cells in a row of a table, it is easiest to use the RowFormat property.

The vertical borders between cells can be specified just using one line of code:

Row.RowFormat.Borders.Vertical.Color = Color.Red;

or

DocumentBuilder.RowFormat.Borders.Vertical.Color = Color.Red;

The key is that the Borders collection on the RowFormat object has Vertical and Horizontal borders in addition to the usual Left, Top, Bottom and Right.

I am closing this issue I suppose. Let us know if you still have a problem.

The issues you have found earlier (filed as 13429) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hello Roman,

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

Thanks for your reply and detail analysis.

Just to make it clear we are using following statements to set cell border color in our actual application

//Set Line Width

documentBuilder.CellFormat.Borders[BorderType.Left].LineWidth = 1;

documentBuilder.CellFormat.Borders[BorderType.Right].LineWidth = 1;

//Set Left Border

documentBuilder.CellFormat.Borders[BorderType.Left].LineStyle = LineStyle.Thick;

documentBuilder.CellFormat.Borders[BorderType.Left].Color = Color.White;

//Set Right Border

documentBuilder.CellFormat.Borders[BorderType.Right].LineStyle = LineStyle.Thick;

documentBuilder.CellFormat.Borders[BorderType.Right].Color = Color.White;

and the sample code we have posted that also takes care of individual border colour setting

documentBuilder.CellFormat.Borders[BorderType.Left].Color = System.Drawing.Color.White;

documentBuilder.CellFormat.Borders[BorderType.Left].LineWidth = 1.0;

Here the problem is with left handside border and not right handside one. We are purposely setting left as well as right border as white though it is not reflecting into PDf output.

I think this is what you are suggesting and that we have aleady done. We have overcome the issue of printing White border in Word format/output but when the same document is converted to PDF, we do not get the same result.

Is this the issue with Word to PDF conversion?

Regards,

Dwarika

Hello

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

Thanks for your request. Yes this is the issue related to Word to PDF converting. This issue is still unresolved, and it is difficult to provide you any reliable estimate regarding this problem. You will be notified as soon as it is fixed.

Best regards,

The issues you have found earlier (filed as WORDSNET-3148) have been fixed in this .NET update and this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.