5

Heyy i am new to novacode docx webapi i want to print a vertical type table without borders, i am have these line of codes through which i be able to print a vertical table i have screen shots also which maybe helpful to u to save my problem

private void Document_3_SecondaryDetail(DocX document, string dist, System.Data.DataTable Doc3_SecondaryDetail)
{
    try
    {

        string headlineText = "";
        string paraOne = "";
        var headLineFormat = new Formatting();
        headLineFormat.FontFamily = new System.Drawing.FontFamily("Arial Black");
        headLineFormat.Size = 18D;
        headLineFormat.Position = 12;
        var paraFormat = new Formatting();
        paraFormat.FontFamily = new System.Drawing.FontFamily("Calibri");
        paraFormat.Size = 10D;
        Novacode.Table SecondaryDetailDoc3 = document.AddTable(Doc3_SecondaryDetail.Select("District = '" + dist + "'").Count() + 1, Doc3_SecondaryDetail.Columns.Count);
        SecondaryDetailDoc3.Alignment = Alignment.left;
        SecondaryDetailDoc3.Design = TableDesign.LightGridAccent1;

        int columnNumber = 0;
        foreach (DataColumn columns in Doc3_SecondaryDetail.Columns)
        {
            SecondaryDetailDoc3.Rows[0].Cells[columnNumber].Paragraphs.First().Append(char.ToUpper(columns.ColumnName[0]) + columns.ColumnName.Substring(1).Replace("_", " "));
            columnNumber++;
        }
        int rowIndex = 1;
        foreach (DataRow row in Doc3_SecondaryDetail.Select("District = '" + dist + "'"))
        {
            int colIndex = 0;
            foreach (var item in row.ItemArray)
            {
                SecondaryDetailDoc3.Rows[rowIndex].Cells[colIndex].Paragraphs.First().Append(item.ToString());
                colIndex++;
            }
            rowIndex++;
        }
        document.InsertParagraph(headlineText, false, headLineFormat);
        document.InsertParagraph(paraOne, false, paraFormat);
        document.InsertTable(SecondaryDetailDoc3);
        document.InsertParagraph("");
        document.Save();
    }
    catch (Exception ex)
    {
    }
}    enter code here

but i want this type of result enter image description here i want verticle style table with no borders This is cuurrent input enter image description here Thanks in advance

JCO9
  • 960
  • 1
  • 15
  • 24
Ali Raza
  • 981
  • 1
  • 8
  • 17

1 Answers1

7

Set the border color to white.

Example:

  table.Rows[i].Cells.Last().SetBorder(TableCellBorderType.Left, new Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));
John
  • 1,011
  • 11
  • 18
  • its displaying empty table and it still showing border – Ali Raza Jul 11 '16 at 10:32
  • Try different values for BorderSize. You can also try Color.Transparent. I definitely managed to get invisible borders. – John Jul 11 '16 at 15:23
  • 1
    Last version of the code was " table.Rows[i].Cells.Last().SetBorder(TableCellBorderType.Left, new Border(BorderStyle.Tcbs_double, BorderSize.one, 1, Color.Transparent));" but it was working with Color.White too for sure. – John Jul 11 '16 at 15:28
  • Alternatively you can use a template document instead of generating a table from scratch. You just need to use DocX.Load method and get the table with document.Tables[0]; – John Jul 11 '16 at 15:30
  • Thanks Alot Bro It Works Now – Ali Raza Jul 12 '16 at 09:33