• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Allegro X PCB Editor
  3. How do I change a cells background color without using a...

Stats

  • Replies 8
  • Subscribers 166
  • Views 18631
  • Members are here 0
More Content

How do I change a cells background color without using a style

iCraig
iCraig over 10 years ago

I'd like to set the background color of a cell based on a pass/fail criteria. I don't really want to create a style for all the various combination, especially since axlSpreadsheetSetStyleParent() doesn't work.


Thanks,

Craig

  • Cancel
  • Sign in to reply
  • DHung
    DHung over 10 years ago

    Hi eDave,

    Your example can work for excel file, right ? (fgrid.il example code in share\pcb\examples\skill\form\grid.)

    I like your way when using these command:

    red = axlSpreadsheetGetRGBColorString(255 0 0)

    axlSpreadsheetSetStyleProp("Fill" "Color" red)

    axlSpreadsheetSetStyleProp("Fill" "Pattern" "Solid")

    But it set color for every cell in excel file. How can it set color for each cell ? Please correct code to set each cell in my code

              axlSpreadsheetInit()
             axlSpreadsheetSetStyle("Default" nil)
            axlSpreadsheetSetStyle("Red" "Red Cell")

     for( i 1 5
           if(i<=3 then
               axlSpreadsheetSetStyleProp("Fill" "Color" axlSpreadsheetGetRGBColorString(0 255 0)) ;green
           ) 
          if( i>3 then
              axlSpreadsheetSetStyleProp("Fill" "Color" axlSpreadsheetGetRGBColorString(0 0 255)) ;blue
           )
          axlSpreadsheetSetStyleProp("Fill" "Pattern" "Solid")
          axlSpreadsheetSetWorksheet("First") 
          axlSpreadsheetDefineCell(i 1 "Red" "String" "ABC")
     ) 

    axlSpreadsheetWrite(v_file_destination)
    axlSpreadsheetClose()

    Return result:

    ABC
    ABC
    ABC
    ABC
    ABC
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • DHung
    DHung over 10 years ago

    I found the way can set background color for each cell when exporting to excel:

     axlSpreadsheetInit()
     axlSpreadsheetSetWorksheet("First")
     
     for( i 1 5
      if(i==1 then
       axlSpreadsheetSetStyleParent("Default")
       axlSpreadsheetDefineCell(i 1 "Default" "String" "Default")
      )
      if(i==2 then
       axlSpreadsheetSetStyle("1" "1")
       axlSpreadsheetSetStyleProp("Fill" "Color" axlSpreadsheetGetRGBColorString(255 0 0)) ;red
       axlSpreadsheetDefineCell(i 1 "1" "String" "Red")
      )
      if(i==3 then
       axlSpreadsheetSetStyle("2" "2")
       axlSpreadsheetSetStyleProp("Fill" "Color" axlSpreadsheetGetRGBColorString(0 255 0)) ;green
       axlSpreadsheetDefineCell(i 1 "2" "String" "Green")
      )
      if(i==4 then
       axlSpreadsheetSetStyle("3" "3")
       axlSpreadsheetSetStyleProp("Fill" "Color" axlSpreadsheetGetRGBColorString(0 0 255)) ;blue
       axlSpreadsheetDefineCell(i 1 "3" "String" "Blue")
      )
      if(i==5 then
       axlSpreadsheetSetStyle("4" "4")
       axlSpreadsheetSetStyleProp("Fill" "Color" axlSpreadsheetGetRGBColorString(255 255 0)) ;yellow
       axlSpreadsheetDefineCell(i 1 "4" "String" "Yellow")
      )
      axlSpreadsheetSetStyleProp("Fill" "Pattern" "Solid")
     )
     axlSpreadsheetWrite(v_file_destination)
     axlSpreadsheetClose()

    Results:

    Default
    Red
    Green
    Blue
    Yellow
    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
  • seyerfred
    seyerfred over 10 years ago

    Is there any way can merge the two or more cell?

    Thank you

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Cancel
<
Cadence Guidelines

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2026 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information