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);
}
我添加了“再次”的代码,因为第一是行不通的:不加粗,不左对齐,无背景颜色。但所有这些事情现在都在起作用。边界不是,但是...为什么不呢?之前的边界是为整张纸张完成的,直到我将第一行重新格式化为止,因为第一次尝试不起作用。 –