Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

can anyone tell me why this code results in a style that only has the left edge set to xlhairline & the others are set to nothing? & when I edit the style in XL, it says that the border is set to left.

        GrayStyle = wbWorkbook.Styles.Add("gray")

       GrayStyle.Interior.Pattern = Excel.XlPattern.xlPatternSolid
       GrayStyle.Interior.PatternColorIndex = Excel.XlColorIndex.xlColorIndexAutomatic
       GrayStyle.Interior.ThemeColor = Excel.XlThemeColor.xlThemeColorDark2
       GrayStyle.Interior.TintAndShade = -0.0999786370433668
       GrayStyle.Interior.PatternTintAndShade = 0

       GrayStyle.Borders(Excel.XlBordersIndex.xlInsideVertical).LineStyle = Excel.XlBorderWeight.xlHairline
       GrayStyle.Borders(Excel.XlBordersIndex.xlInsideVertical).LineStyle = Excel.XlLineStyle.xlContinuous

       GrayStyle.Borders(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlBorderWeight.xlHairline
       GrayStyle.Borders(Excel.XlBordersIndex.xlInsideHorizontal).LineStyle = Excel.XlLineStyle.xlContinuous

       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlBorderWeight.xlHairline
       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeLeft).LineStyle = Excel.XlLineStyle.xlContinuous

       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlBorderWeight.xlHairline
       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeRight).LineStyle = Excel.XlLineStyle.xlContinuous

       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlBorderWeight.xlHairline
       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeTop).LineStyle = Excel.XlLineStyle.xlContinuous

       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlBorderWeight.xlHairline
       GrayStyle.Borders(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous

 

All I really want to do is change the color of some cells without changing the other cell formatting, but I couldn't find any info on doing that, so it seems that I need to create a style for every type of formatting combination I need.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...