2016-09-16 79 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

相關問題