Word:在文档级别指定表格单元格垂直对齐(使用表格样式) [英] Word: specify table cell vertical alignment on the document level (using table style)

查看:237
本文介绍了Word:在文档级别指定表格单元格垂直对齐(使用表格样式)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好, 


我正在生成Word文档,我想知道有没有办法在文档级别指定表格单元格垂直对齐。


目前我正在向每个单元格添加TableCellVerticalAlignment,否则它会与顶部对齐:


 
TableCell tableCell = new TableCell();
TableCellProperties tableCellProperties = new TableCellProperties();
tableCellProperties.Append( new TableCellVerticalAlignment(){Val = TableVerticalAlignmentValues.Center});
// ...
tableCell.Append(tableCellProperties);

// ...
//然后将单元格添加到a行和行到表
tableRow1.Append(tableCell);
table1.append(tableRow1);

解决方案

嗨弗拉基米尔,


我试过了我的身边,但在整个表格的文本居中,然后查看xml信息后,每个单元格都包含对齐信息:


      < w:vAlign w:val =" center" />


因此,我认为我们无法定义全局TableStyle类来设置每个单元格,我们需要将alignment属性应用于每个单元格的属性。


TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment(){Val = TableVerticalAlignmentValues.Center};


tableCellProperties1.Append(tableCellVerticalAlignment1);


Best的问候,&NBSP;


Hello, 

I'm generating Word document and I'm wondering is there a way to specify table cell vertical alignment on the document level.

At the moment I'm adding TableCellVerticalAlignment to each cell, otherwise it's aligned to the top:

	TableCell tableCell = new TableCell();
	TableCellProperties tableCellProperties = new TableCellProperties();
	tableCellProperties.Append(new TableCellVerticalAlignment() { Val = TableVerticalAlignmentValues.Center });
	// ...
	tableCell.Append(tableCellProperties);

	// ...
	// then add cell to a row, and row to a table
	tableRow1.Append(tableCell);
	table1.append(tableRow1);

解决方案

Hi Vladimir,

I tried on my side, but after centering the text for the whole table and then looked into the xml information, each cell contains the alignment information:

      <w:vAlign w:val="center" />

So, I think we can't define a global TableStyle class to set each cell, we need to apply the alignment attribute to each cell's property.

TableCellVerticalAlignment tableCellVerticalAlignment1 = new TableCellVerticalAlignment(){ Val = TableVerticalAlignmentValues.Center };

tableCellProperties1.Append(tableCellVerticalAlignment1);

Best Regards, 


这篇关于Word:在文档级别指定表格单元格垂直对齐(使用表格样式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆