[英]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.