我尝试使用类似如下代码(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")
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.