【问题标题】:Libxl background colorsLibxl 背景颜色
【发布时间】:2017-01-13 16:27:11
【问题描述】:

我正在尝试在 libXL 中使用自定义颜色, 我注意到图书馆里有大约80种基本颜色, 有谁知道如何使用这个库为单元格设置自定义颜色,因为在文档中没有任何相关的信息。

现在我尝试执行以下操作:

 $doc = new XL_excel(true);
 $createSheet = $doc->createSheet();
          for( $i=0; $i<32000; $i++ ){
             $format = $doc->excel->addFormat();
             $format->patternForegroundColor($i);
             $format->fillPattern(ExcelFormat::FILLPATTERN_SOLID);
             $doc->excel->getSheet()->setCellFormat(8+$i, 2, $format);
         }

我为这个库得到的所有颜色都是从 1 到 80 的整数 之后我没有颜色或重复的颜色,我尝试使用整数直到 32000

【问题讨论】:

    标签: php c excel libxl


    【解决方案1】:

    我认为还没有自定义颜色可用,另请参阅官方 libxl 文档http://libxl.com/colors.html

    【讨论】:

      【解决方案2】:

      使用book 对象的colorPack 方法。请确保 rgbMode 设置为 true。在 C# 中:

      book.rgbMode = true;
      someFormat.patternForegroundColor = book.colorPack(217,217,217);
      

      http://www.libxl.com/workbook.html

      【讨论】:

        【解决方案3】:

        gabortoth,谢谢你,你的回答对我很有帮助。我发现了另一个功能。当 rgbmode 打开时,带有预设颜色的常量将停止正常工作。自己制作并使用它们。 不仅无法理解如何处理常量

        const COLOR_DEFAULT_FOREGROUND = 64;
        const COLOR_DEFAULT_BACKGROUND = 65;
        

        我在下面引用的其余部分

        const RGB_COLOR_BLACK = 0;
        const RGB_COLOR_WHITE = 16777215;
        const RGB_COLOR_RED = 16711680;
        const RGB_COLOR_BRIGHTGREEN = 65280;
        const RGB_COLOR_BLUE = 255;
        const RGB_COLOR_YELLOW = 16776960;
        const RGB_COLOR_PINK = 16711935;
        const RGB_COLOR_TURQUOISE = 65535;
        const RGB_COLOR_DARKRED = 8388608;
        const RGB_COLOR_GREEN = 32768;
        const RGB_COLOR_DARKBLUE = 128;
        const RGB_COLOR_DARKYELLOW = 8421376;
        const RGB_COLOR_VIOLET = 8388736;
        const RGB_COLOR_TEAL = 32896;
        const RGB_COLOR_GRAY25 = 12632256;
        const RGB_COLOR_GRAY50 = 8421504;
        const RGB_COLOR_PERIWINKLE_CF = 10066431;
        const RGB_COLOR_PLUM_CF = 10040166;
        const RGB_COLOR_IVORY_CF = 16777164;
        const RGB_COLOR_LIGHTTURQUOISE_CF = 13434879;
        const RGB_COLOR_DARKPURPLE_CF = 6684774;
        const RGB_COLOR_CORAL_CF = 16744576;
        const RGB_COLOR_OCEANBLUE_CF = 26316;
        const RGB_COLOR_ICEBLUE_CF = 13421823;
        const RGB_COLOR_DARKBLUE_CL = 128;
        const RGB_COLOR_PINK_CL = 16711935;
        const RGB_COLOR_YELLOW_CL = 16776960;
        const RGB_COLOR_TURQUOISE_CL = 65535;
        const RGB_COLOR_VIOLET_CL = 8388736;
        const RGB_COLOR_DARKRED_CL = 8388608;
        const RGB_COLOR_TEAL_CL = 32896;
        const RGB_COLOR_BLUE_CL = 255;
        const RGB_COLOR_SKYBLUE = 52479;
        const RGB_COLOR_LIGHTTURQUOISE = 13434879;
        const RGB_COLOR_LIGHTGREEN = 13434828;
        const RGB_COLOR_LIGHTYELLOW = 16777113;
        const RGB_COLOR_PALEBLUE = 10079487;
        const RGB_COLOR_ROSE = 16751052;
        const RGB_COLOR_LAVENDER = 13408767;
        const RGB_COLOR_TAN = 16764057;
        const RGB_COLOR_LIGHTBLUE = 3368703;
        const RGB_COLOR_AQUA = 3394764;
        const RGB_COLOR_LIME = 10079232;
        const RGB_COLOR_GOLD = 16763904;
        const RGB_COLOR_LIGHTORANGE = 16750848;
        const RGB_COLOR_ORANGE = 16737792;
        const RGB_COLOR_BLUEGRAY = 6710937;
        const RGB_COLOR_GRAY40 = 9868950;
        const RGB_COLOR_DARKTEAL = 13158;
        const RGB_COLOR_SEAGREEN = 3381606;
        const RGB_COLOR_DARKGREEN = 13056;
        const RGB_COLOR_OLIVEGREEN = 3355392;
        const RGB_COLOR_BROWN = 10040064;
        const RGB_COLOR_PLUM = 10040166;
        const RGB_COLOR_INDIGO = 3355545;
        const RGB_COLOR_GRAY80 = 3355443;
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-04-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2019-08-30
          • 1970-01-01
          • 2015-11-29
          相关资源
          最近更新 更多