我尝试使用类似如下代码(VB.NET)进行更改,但单元格的其它样式也被更改了(变成默认值)。
Dim tempRow As Row = worksheet.Cells.Rows(1)
Dim tempStyle As Style = tempRow.Style
tempStyle.ForegroundColor = Color.Empty
tempRow.ApplyStyle(tempStyle, StyleFlag)
Dim workbook As Workbook = New Workbook("e:\test2\Book1.xlsx")
Dim worksheet As Worksheet = workbook.Worksheets(0)
Dim tempRow As Row = worksheet.Cells.Rows(1)
Dim tempStyle As Style = tempRow.Style
tempStyle.ForegroundColor = Color.Empty
tempStyle.Pattern = BackgroundType.None
Dim styleFlag As StyleFlag = New StyleFlag()
styleFlag.CellShading = True
tempRow.ApplyStyle(tempStyle, styleFlag)
workbook.Save("e:\test2\out1.xlsx")