0
我有下面的代碼添加邊框行:爲什麼邊框沒有應用到我的首行(Aspose Cells)?
Range _range;
_range = customerWorksheet.Cells.CreateRange("A1", "P1");
_range.SetOutlineBorders(CellBorderType.Hair, Color.Black);
...但它不工作 - 無國界出現在該頂行(行「1」):
不爲什麼,以及如何我可以添加這些邊界,因爲它們是在表的其餘部分做了什麼?
下面的碼作爲頂行的一個片段,示出一個單元是如何加入:
Cell PAItemCell = customerWorksheet.Cells[rowToPopulate, PAITEMCODE_COL];
PAItemCell.PutValue(frbdbc.PAItemCode, true);
var paiStyle = PAItemCell.GetStyle();
paiStyle.Font.Name = fontForSheets;
paiStyle.IsTextWrapped = false;
PAItemCell.SetStyle(paiStyle);
而這裏的邊界是如何加入到片材(理論上的數據部分,它應該爲工作也沒有上述嘗試,甚至沒有必要):
private void BorderizeDataPortionOfCustomerSheet()
{
int rowsUsed = customerWorksheet.Cells.Rows.Count;
int colsUsed = SHIPVARIANCE_COL;
string bottomRightRange = string.Format("P{0}", rowsUsed);
var range = customerWorksheet.Cells.CreateRange("A1", bottomRightRange);
//Setting border for each cell in the range
var style = workBook.CreateStyle();
style.SetBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
style.SetBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Black);
style.SetBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);
style.SetBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Black);
for (int r = range.FirstRow; r < range.RowCount; r++)
{
for (int c = range.FirstColumn; c < range.ColumnCount; c++)
{
Cell cell = customerWorksheet.Cells[r, c];
cell.SetStyle(style, new StyleFlag()
{
TopBorder = true,
BottomBorder = true,
LeftBorder = true,
RightBorder = true
});
}
}
//Setting outline border to range
range.SetOutlineBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Black);
range.SetOutlineBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
range.SetOutlineBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Black);
range.SetOutlineBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);
customerWorksheet.FreezePanes(FIRST_DATA_ROW, SHORTNAME_COL, rowsUsed, colsUsed);
}
我添加了「再次」的代碼,因爲第一是行不通的:不加粗,不左對齊,無背景顏色。但所有這些事情現在都在起作用。邊界不是,但是...爲什麼不呢?之前的邊界是爲整張紙張完成的,直到我將第一行重新格式化爲止,因爲第一次嘗試不起作用。 –