嘿,我是新手,想使用Novacode Docx WebAPI打印一个没有边框的竖向表格。我有以下代码可以打印出这样的表格。我也有屏幕截图,可能对解决我的问题有帮助。
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
但我想要这种类型的结果
![enter image description here](https://istack.dev59.com/B1d3A.webp)
![enter image description here](https://istack.dev59.com/sAgEm.webp)