VB.net Excel styling
Hey all i am trying to add some style properties to a column but the code i am currently using doesnt seem to work at all?
Dim oApp As New Excel.Application
Dim oWB As Excel.Workbook = oApp.Workbooks.Add()
Dim oWS As Excel.Worksheet = CType(oWB.Worksheets(1), Excel.Worksheet)
Dim style As Microsoft.Office.Interop.Excel.Style
style = oWB.Styles.Add("Style1")
style.NumberFormat = "Text"
style.Font.Name = "Arial"
style.Font.Bold = True
style.Font.Size = 5
style.Interior.Pattern = Micro开发者_高级运维soft.Office.Interop.Excel.XlPattern.xlPatternSolid
oWS.Cells(1, 1) = "repairinv PROG"
oWS.Cells(1, 2) = "repairinv TEST"
It's still the same as "default" would look when just opening up excel for the first time.
Any help would be great! :o)
David
You need to set the style of the .Cell
range to the style you want. E.g.:
oWS.Cells(1, 1).Style = "Style1"
oWS.Cells(1, 2).Style = "Style1"
精彩评论