如何从颜色表中查找RTF表格单元格颜色

时间:2012-11-07 12:10:48

标签: c# rtf

我想从RTF文件中读取表格内容以及表格单元格颜色信息。在我的RTF文件中,颜色表定义为

{\colortbl;
\red0\green0\blue0;
\red0\green0\blue255;
\red0\green255\blue255;
\red0\green255\blue0;
\red255\green0\blue255;
\red255\green0\blue0;
\red255\green255\blue0;
\red255\green255\blue255;
\red0\green0\blue128;
\red0\green128\blue0;
\red128\green0\blue128;
\red128\green0\blue0;
\red128\green128\blue0;
\red128\green128\blue128;
\red192\green192\blue192;
}

我有表头行的RTF,

\trowd \trql\trgaph90\trleft-90\trautofit1
\clvertalt
\clbrdrl\brdrs\brdrw15\brdrcf1
\clbrdrt\brdrs\brdrw15\brdrcf1
\clbrdrr\brdrs\brdrw15\brdrcf1
\clbrdrb\brdrs\brdrw15\brdrcf1
\clcfpat7\clcbpat8\clshdng2000
\cellx1440
\clvertalt
\clbrdrl\brdrs\brdrw15\brdrcf1
\clbrdrt\brdrs\brdrw15\brdrcf1
\clbrdrr\brdrs\brdrw15\brdrcf1
\clbrdrb\brdrs\brdrw15\brdrcf1
\clcfpat7\clcbpat8\clshdng2000
\cellx2970
\pard
\intbl \widctlpar\keep\hyphpar0
\li0\ri0\fi0
\ql{Product Name\cell
}{Price\cell}\row

表格单元格背景信息以“\ clcfpat7 \ clcbpat8 \ clshdng2000”命名。

请帮我从颜色信息中找到表格单元格的正确颜色。

1 个答案:

答案 0 :(得分:2)

颜色按索引顺序

{\colortbl;
  1 =  \red0\green0\blue0;
  2 =  \red0\green0\blue255;
  3 =  \red0\green255\blue255;
  4 =  \red0\green255\blue0;
  5 =  \red255\green0\blue255;
  6 =  \red255\green0\blue0;
  7 =  \red255\green255\blue0;
  8 =  \red255\green255\blue255;
  9 =  \red0\green0\blue128;
  10 = \red0\green128\blue0;
  11 = \red128\green0\blue128;
  12 = \red128\green0\blue0;
  13 = \red128\green128\blue0;
  14 = \red128\green128\blue128;
  15 = \red192\green192\blue192;
}

这个控件\clcbpat8说的是,在列表中绘制颜色为8的单元格的背景。将它改为9,你会变成深蓝色。