Cell border type varying in table

Hello,

I am trying to set different borders on a table, and there seems to be no difference between single, thick, and hairline. 

Here is a code example and attached is the code output. Can you confirm or explain how to set a thick border around the header row and different border styles for top and bottom and right and left? 


 var document = new WordDocument();

 document.EnsureMinimal();


 var table = document.LastSection.AddTable();

 table.ResetCells(3, 4);

 //table.TableFormat.Borders.BorderType = BorderStyle.None;


 table.Rows[0].Cells[0].CellFormat.Borders.BorderType = BorderStyle.Single;

 table.Rows[0].Cells[1].CellFormat.Borders.BorderType = BorderStyle.Single;

 table.Rows[0].Cells[2].CellFormat.Borders.BorderType = BorderStyle.Single;


 table.Rows[1].Cells[0].CellFormat.Borders.BorderType = BorderStyle.Thick;

 table.Rows[1].Cells[1].CellFormat.Borders.BorderType = BorderStyle.Thick;

 table.Rows[1].Cells[2].CellFormat.Borders.BorderType = BorderStyle.Thick;


 table.Rows[2].Cells[0].CellFormat.Borders.BorderType = BorderStyle.Hairline;

 table.Rows[2].Cells[1].CellFormat.Borders.BorderType = BorderStyle.Hairline;

 table.Rows[2].Cells[2].CellFormat.Borders.BorderType = BorderStyle.Hairline;


Attachment: SyncfusionReport_1d0fc0ac.zip

1 Reply 1 reply marked as answer

LB Lokesh Baskar Syncfusion Team January 9, 2024 08:39 PM UTC

Hi Natalie, From the given details, we have found that your requirement is to set a different cell border style for the top, right, left, and bottom borders. To achieve your requirement, we have prepared a sample application, which can be downloaded from the link below. We have also attached the output word document for your reference.
In the sample application below, we have done the following:

1. Created a word document.

2. Added a table with three rows and three columns.

3. Applied the required cell border style for the top, bottom, right, and left borders with the desired line width.

4. Saved the word document.


If we have misunderstood any of your requirements, please share the expected output document (manually modified using Microsoft Word application) with us. We will review your requirements and provide you with the appropriate solution as soon as possible.


Attachment: ApplyCellBorderStyle_39028976.zip

Marked as answer
Loader.
Up arrow icon