2016-09-16 78 views

回答

1

参见: https://blogs.msdn.microsoft.com/chrisquon/2009/11/30/stylizing-your-excel-worksheets-with-open-xml-2-0/

为了您的具体问题,我会遍历各行中的细胞,直到你发现需要国界的,然后应用格式:(注意DesiredCell是为你添加单元格引用检查)

foreach(Row row in sheetData.Elements<Row>) 
{ 
    foreach(Cell cell in row.Elements<Cell>) 
    { 
    if(cell.CellReference == DesiredCell) 
     { 
     cell = new Cell(new CellValue(“ ”)) { DataType = CellValues.String, StyleIndex = 1 }; 
     } 
    } 
} 

您还必须从上面的链接添加样式索引。

+0

谢谢你的回答。但是设置边框的过程非常漫长,我需要单独设置所有单元格样式。 – Divyesh

+0

不可能选择单元格范围并在其上设置边框? – Divyesh

相关问题