0

我正在尝试在 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

在此处输入图像描述

4

3 回答 3

0

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;
于 2019-02-21T06:38:30.697 回答
0

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

于 2016-09-06T21:42:53.393 回答
0

使用book对象的colorPack方法。可以肯定的是,rgbMode设置为true。在 C# 中:

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

请参阅http://www.libxl.com/workbook.html

于 2016-09-27T13:56:52.247 回答