![](/img/trans.png)
[英]MySQL IN clause: How can I get multiple rows when I use a same value multiple times?
[英]How can I get a value to expand over multiple rows in Excel?
我需要放置一个跨越四行的文本值。 我认为/希望这样做会起作用:
private int curDescriptionTopRow = 8;
. . .
private void AddDescription(String desc)
{
int curDescriptionBottomRow = curDescriptionTopRow + 3;
_xlSheet.Range[_xlSheet.Cells[curDescriptionTopRow, 1], _xlSheet.Cells[curDescriptionBottomRow, 1]].Font.Bold = true;
_xlSheet.Range[_xlSheet.Cells[curDescriptionTopRow, 1], _xlSheet.Cells[curDescriptionBottomRow, 1]].VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
_xlSheet.Range[_xlSheet.Cells[curDescriptionTopRow, 1], _xlSheet.Cells[curDescriptionBottomRow, 1]].Value2 = desc;
curDescriptionTopRow = curDescriptionTopRow + 4;
}
我需要第一个描述以垂直居中的方式显示在单元格A8-A11中(列A,第8-11行)。
上面的代码在所有四行中添加了描述,而不是在四行中仅添加了一次。
如何防止描述的三个重复出现?
定义然后合并范围是可行的:
private int curDescriptionTopRow = 8;
. . .
private void AddDescription(String desc)
{
int curDescriptionBottomRow = curDescriptionTopRow + 3;
var range =
_xlSheet.Range[_xlSheet.Cells[curDescriptionTopRow, 1], _xlSheet.Cells[curDescriptionBottomRow, 1]];
range.Merge();
range.Font.Bold = true;
range.VerticalAlignment = Microsoft.Office.Interop.Excel.XlVAlign.xlVAlignCenter;
range.Value2 = desc;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.