You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TestXSSFFont.java 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.xssf.usermodel;
  16. import static org.apache.poi.ss.usermodel.FontCharset.*;
  17. import static org.junit.jupiter.api.Assertions.*;
  18. import java.io.IOException;
  19. import java.util.Arrays;
  20. import java.util.stream.Stream;
  21. import org.apache.poi.common.usermodel.fonts.FontCharset;
  22. import org.apache.poi.ooxml.POIXMLException;
  23. import org.apache.poi.ss.usermodel.BaseTestFont;
  24. import org.apache.poi.ss.usermodel.Cell;
  25. import org.apache.poi.ss.usermodel.Font;
  26. import org.apache.poi.ss.usermodel.FontFamily;
  27. import org.apache.poi.ss.usermodel.FontScheme;
  28. import org.apache.poi.ss.usermodel.FontUnderline;
  29. import org.apache.poi.ss.usermodel.IndexedColors;
  30. import org.apache.poi.ss.usermodel.Row;
  31. import org.apache.poi.ss.usermodel.Sheet;
  32. import org.apache.poi.ss.usermodel.Workbook;
  33. import org.apache.poi.ss.util.SheetUtil;
  34. import org.apache.poi.util.LocaleUtil;
  35. import org.apache.poi.xssf.XSSFITestDataProvider;
  36. import org.apache.poi.xssf.XSSFTestDataSamples;
  37. import org.junit.jupiter.api.Test;
  38. import org.junit.jupiter.params.provider.Arguments;
  39. import org.openxmlformats.schemas.officeDocument.x2006.sharedTypes.STVerticalAlignRun;
  40. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBooleanProperty;
  41. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
  42. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
  43. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontFamily;
  44. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontName;
  45. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontScheme;
  46. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFontSize;
  47. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTIntProperty;
  48. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTUnderlineProperty;
  49. import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTVerticalAlignFontProperty;
  50. import org.openxmlformats.schemas.spreadsheetml.x2006.main.STFontScheme;
  51. import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnderlineValues;
  52. public final class TestXSSFFont extends BaseTestFont {
  53. public TestXSSFFont() {
  54. super(XSSFITestDataProvider.instance);
  55. }
  56. @SuppressWarnings("unused")
  57. public static Stream<Arguments> defaultFont() {
  58. return Stream.of(Arguments.of("Calibri", (short) 220, IndexedColors.BLACK.getIndex()));
  59. }
  60. @Test
  61. void testConstructor() {
  62. XSSFFont xssfFont=new XSSFFont();
  63. assertNotNull(xssfFont.getCTFont());
  64. }
  65. @Test
  66. void testBold() {
  67. CTFont ctFont=CTFont.Factory.newInstance();
  68. CTBooleanProperty bool=ctFont.addNewB();
  69. bool.setVal(false);
  70. ctFont.setBArray(0,bool);
  71. XSSFFont xssfFont=new XSSFFont(ctFont);
  72. assertFalse(xssfFont.getBold());
  73. xssfFont.setBold(true);
  74. assertEquals(1,ctFont.sizeOfBArray());
  75. assertTrue(ctFont.getBArray(0).getVal());
  76. }
  77. @SuppressWarnings("deprecation")
  78. @Test
  79. void testCharSetWithDeprecatedFontCharset() throws IOException {
  80. CTFont ctFont=CTFont.Factory.newInstance();
  81. CTIntProperty prop=ctFont.addNewCharset();
  82. prop.setVal(ANSI.getValue());
  83. ctFont.setCharsetArray(0,prop);
  84. XSSFFont xssfFont=new XSSFFont(ctFont);
  85. assertEquals(Font.ANSI_CHARSET,xssfFont.getCharSet());
  86. xssfFont.setCharSet(DEFAULT);
  87. assertEquals(DEFAULT.getValue(),ctFont.getCharsetArray(0).getVal());
  88. // Try with a few less usual ones:
  89. // Set with the Charset itself
  90. xssfFont.setCharSet(RUSSIAN);
  91. assertEquals(RUSSIAN.getValue(), xssfFont.getCharSet());
  92. // And set with the Charset index
  93. xssfFont.setCharSet(ARABIC.getValue());
  94. assertEquals(ARABIC.getValue(), xssfFont.getCharSet());
  95. xssfFont.setCharSet((byte)(ARABIC.getValue()));
  96. assertEquals(ARABIC.getValue(), xssfFont.getCharSet());
  97. // This one isn't allowed
  98. assertNull(valueOf(9999));
  99. assertThrows(POIXMLException.class, () -> xssfFont.setCharSet(9999),
  100. "Shouldn't be able to set an invalid charset");
  101. // Now try with a few sample files
  102. // Normal charset
  103. try (XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx")) {
  104. assertEquals(0,
  105. wb1.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFont().getCharSet()
  106. );
  107. }
  108. // GB2312 charset
  109. try (XSSFWorkbook wb2 = XSSFTestDataSamples.openSampleWorkbook("49273.xlsx")) {
  110. assertEquals(134,
  111. wb2.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFont().getCharSet()
  112. );
  113. }
  114. }
  115. @Test
  116. void testCharSet() throws IOException {
  117. CTFont ctFont=CTFont.Factory.newInstance();
  118. CTIntProperty prop=ctFont.addNewCharset();
  119. prop.setVal(FontCharset.ANSI.getNativeId());
  120. ctFont.setCharsetArray(0,prop);
  121. XSSFFont xssfFont=new XSSFFont(ctFont);
  122. assertEquals(Font.ANSI_CHARSET,xssfFont.getCharSet());
  123. xssfFont.setCharSet(FontCharset.DEFAULT);
  124. assertEquals(FontCharset.DEFAULT.getNativeId(),ctFont.getCharsetArray(0).getVal());
  125. // Try with a few less usual ones:
  126. // Set with the Charset itself
  127. xssfFont.setCharSet(FontCharset.RUSSIAN);
  128. assertEquals(FontCharset.RUSSIAN.getNativeId(), xssfFont.getCharSet());
  129. // And set with the Charset index
  130. xssfFont.setCharSet(FontCharset.ARABIC.getNativeId());
  131. assertEquals(FontCharset.ARABIC.getNativeId(), xssfFont.getCharSet());
  132. xssfFont.setCharSet((byte)(FontCharset.ARABIC.getNativeId()));
  133. assertEquals(FontCharset.ARABIC.getNativeId(), xssfFont.getCharSet());
  134. // This one isn't allowed
  135. assertNull(FontCharset.valueOf(9999));
  136. assertThrows(POIXMLException.class, () -> xssfFont.setCharSet(9999), "Shouldn't be able to set an invalid charset");
  137. // Now try with a few sample files
  138. // Normal charset
  139. try (XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("Formatting.xlsx")) {
  140. assertEquals(0,
  141. wb1.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFont().getCharSet()
  142. );
  143. }
  144. // GB2312 charset
  145. try (XSSFWorkbook wb2 = XSSFTestDataSamples.openSampleWorkbook("49273.xlsx")) {
  146. assertEquals(134,
  147. wb2.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFont().getCharSet()
  148. );
  149. }
  150. }
  151. @Test
  152. void testFontName() {
  153. CTFont ctFont=CTFont.Factory.newInstance();
  154. CTFontName fname=ctFont.addNewName();
  155. fname.setVal("Arial");
  156. ctFont.setNameArray(0,fname);
  157. XSSFFont xssfFont=new XSSFFont(ctFont);
  158. assertEquals("Arial", xssfFont.getFontName());
  159. xssfFont.setFontName("Courier");
  160. assertEquals("Courier",ctFont.getNameArray(0).getVal());
  161. }
  162. @Test
  163. void testItalic() {
  164. CTFont ctFont=CTFont.Factory.newInstance();
  165. CTBooleanProperty bool=ctFont.addNewI();
  166. bool.setVal(false);
  167. ctFont.setIArray(0,bool);
  168. XSSFFont xssfFont=new XSSFFont(ctFont);
  169. assertFalse(xssfFont.getItalic());
  170. xssfFont.setItalic(true);
  171. assertEquals(1,ctFont.sizeOfIArray());
  172. assertTrue(ctFont.getIArray(0).getVal());
  173. assertTrue(ctFont.getIArray(0).getVal());
  174. }
  175. @Test
  176. void testStrikeout() {
  177. CTFont ctFont=CTFont.Factory.newInstance();
  178. CTBooleanProperty bool=ctFont.addNewStrike();
  179. bool.setVal(false);
  180. ctFont.setStrikeArray(0,bool);
  181. XSSFFont xssfFont=new XSSFFont(ctFont);
  182. assertFalse(xssfFont.getStrikeout());
  183. xssfFont.setStrikeout(true);
  184. assertEquals(1,ctFont.sizeOfStrikeArray());
  185. assertTrue(ctFont.getStrikeArray(0).getVal());
  186. assertTrue(ctFont.getStrikeArray(0).getVal());
  187. }
  188. @Test
  189. void testFontHeight() {
  190. CTFont ctFont=CTFont.Factory.newInstance();
  191. CTFontSize size=ctFont.addNewSz();
  192. size.setVal(11);
  193. ctFont.setSzArray(0,size);
  194. XSSFFont xssfFont=new XSSFFont(ctFont);
  195. assertEquals(11,xssfFont.getFontHeightInPoints());
  196. xssfFont.setFontHeight(20);
  197. assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
  198. }
  199. @Test
  200. void testFontHeightInPoint() {
  201. CTFont ctFont=CTFont.Factory.newInstance();
  202. CTFontSize size=ctFont.addNewSz();
  203. size.setVal(14);
  204. ctFont.setSzArray(0,size);
  205. XSSFFont xssfFont=new XSSFFont(ctFont);
  206. assertEquals(14,xssfFont.getFontHeightInPoints());
  207. xssfFont.setFontHeightInPoints((short)20);
  208. assertEquals(20.0, ctFont.getSzArray(0).getVal(), 0.0);
  209. }
  210. @Test
  211. void testUnderline() {
  212. CTFont ctFont=CTFont.Factory.newInstance();
  213. CTUnderlineProperty underlinePropr=ctFont.addNewU();
  214. underlinePropr.setVal(STUnderlineValues.SINGLE);
  215. ctFont.setUArray(0,underlinePropr);
  216. XSSFFont xssfFont=new XSSFFont(ctFont);
  217. assertEquals(Font.U_SINGLE, xssfFont.getUnderline());
  218. xssfFont.setUnderline(Font.U_DOUBLE);
  219. assertEquals(1, ctFont.sizeOfUArray());
  220. assertSame(STUnderlineValues.DOUBLE,ctFont.getUArray(0).getVal());
  221. xssfFont.setUnderline(FontUnderline.DOUBLE_ACCOUNTING);
  222. assertEquals(1, ctFont.sizeOfUArray());
  223. assertSame(STUnderlineValues.DOUBLE_ACCOUNTING,ctFont.getUArray(0).getVal());
  224. }
  225. @Test
  226. void testColor() {
  227. CTFont ctFont=CTFont.Factory.newInstance();
  228. CTColor color=ctFont.addNewColor();
  229. color.setIndexed(XSSFFont.DEFAULT_FONT_COLOR);
  230. ctFont.setColorArray(0,color);
  231. XSSFFont xssfFont=new XSSFFont(ctFont);
  232. assertEquals(IndexedColors.BLACK.getIndex(),xssfFont.getColor());
  233. xssfFont.setColor(IndexedColors.RED.getIndex());
  234. assertEquals(IndexedColors.RED.getIndex(), ctFont.getColorArray(0).getIndexed());
  235. }
  236. @Test
  237. void testRgbColor() {
  238. CTFont ctFont=CTFont.Factory.newInstance();
  239. CTColor color=ctFont.addNewColor();
  240. color.setRgb(Integer.toHexString(0xFFFFFF).getBytes(LocaleUtil.CHARSET_1252));
  241. ctFont.setColorArray(0,color);
  242. XSSFFont xssfFont=new XSSFFont(ctFont);
  243. assertEquals(ctFont.getColorArray(0).getRgb()[0],xssfFont.getXSSFColor().getRGB()[0]);
  244. assertEquals(ctFont.getColorArray(0).getRgb()[1],xssfFont.getXSSFColor().getRGB()[1]);
  245. assertEquals(ctFont.getColorArray(0).getRgb()[2],xssfFont.getXSSFColor().getRGB()[2]);
  246. assertEquals(ctFont.getColorArray(0).getRgb()[3],xssfFont.getXSSFColor().getRGB()[3]);
  247. xssfFont.setColor((short)23);
  248. byte[] bytes = Integer.toHexString(0xF1F1F1).getBytes(LocaleUtil.CHARSET_1252);
  249. color.setRgb(bytes);
  250. XSSFColor newColor = XSSFColor.from(color);
  251. xssfFont.setColor(newColor);
  252. assertEquals(ctFont.getColorArray(0).getRgb()[2],newColor.getRGB()[2]);
  253. assertArrayEquals(bytes, xssfFont.getXSSFColor().getRGB());
  254. assertEquals(0, xssfFont.getColor());
  255. }
  256. @Test
  257. void testThemeColor() {
  258. CTFont ctFont=CTFont.Factory.newInstance();
  259. CTColor color=ctFont.addNewColor();
  260. color.setTheme(1);
  261. ctFont.setColorArray(0,color);
  262. XSSFFont xssfFont=new XSSFFont(ctFont);
  263. assertEquals(ctFont.getColorArray(0).getTheme(),xssfFont.getThemeColor());
  264. xssfFont.setThemeColor(IndexedColors.RED.getIndex());
  265. assertEquals(IndexedColors.RED.getIndex(),ctFont.getColorArray(0).getTheme());
  266. }
  267. @Test
  268. void testFamily() {
  269. CTFont ctFont=CTFont.Factory.newInstance();
  270. CTFontFamily family=ctFont.addNewFamily();
  271. family.setVal(FontFamily.MODERN.getValue());
  272. ctFont.setFamilyArray(0,family);
  273. XSSFFont xssfFont=new XSSFFont(ctFont);
  274. assertEquals(FontFamily.MODERN.getValue(),xssfFont.getFamily());
  275. }
  276. @Test
  277. void testScheme() {
  278. CTFont ctFont=CTFont.Factory.newInstance();
  279. CTFontScheme scheme=ctFont.addNewScheme();
  280. scheme.setVal(STFontScheme.MAJOR);
  281. ctFont.setSchemeArray(0,scheme);
  282. XSSFFont font=new XSSFFont(ctFont);
  283. assertEquals(FontScheme.MAJOR,font.getScheme());
  284. font.setScheme(FontScheme.NONE);
  285. assertSame(STFontScheme.NONE,ctFont.getSchemeArray(0).getVal());
  286. }
  287. @Test
  288. void testTypeOffset() {
  289. CTFont ctFont=CTFont.Factory.newInstance();
  290. CTVerticalAlignFontProperty valign=ctFont.addNewVertAlign();
  291. valign.setVal(STVerticalAlignRun.BASELINE);
  292. ctFont.setVertAlignArray(0,valign);
  293. XSSFFont font=new XSSFFont(ctFont);
  294. assertEquals(Font.SS_NONE,font.getTypeOffset());
  295. font.setTypeOffset(XSSFFont.SS_SUPER);
  296. assertSame(STVerticalAlignRun.SUPERSCRIPT,ctFont.getVertAlignArray(0).getVal());
  297. }
  298. // store test from TestSheetUtil here as it uses XSSF
  299. @Test
  300. void testCanComputeWidthXSSF() throws IOException {
  301. try (Workbook wb = new XSSFWorkbook()) {
  302. // cannot check on result because on some machines we get back false here!
  303. assertDoesNotThrow(() -> SheetUtil.canComputeColumnWidth(wb.getFontAt(0)));
  304. }
  305. }
  306. // store test from TestSheetUtil here as it uses XSSF
  307. @Test
  308. void testCanComputeWidthInvalidFont() {
  309. Font font = new XSSFFont(CTFont.Factory.newInstance());
  310. font.setFontName("some non existing font name");
  311. // Even with invalid fonts we still get back useful data most of the time...
  312. assertDoesNotThrow(() -> SheetUtil.canComputeColumnWidth(font));
  313. }
  314. /**
  315. * Test that fonts get added properly
  316. */
  317. @Test
  318. void testFindFont() throws IOException {
  319. try (XSSFWorkbook wb = new XSSFWorkbook()) {
  320. assertEquals(1, wb.getNumberOfFonts());
  321. XSSFSheet s = wb.createSheet();
  322. s.createRow(0);
  323. s.createRow(1);
  324. s.getRow(0).createCell(0);
  325. s.getRow(1).createCell(0);
  326. assertEquals(1, wb.getNumberOfFonts());
  327. XSSFFont f1 = wb.getFontAt(0);
  328. assertFalse(f1.getBold());
  329. // Check that asking for the same font
  330. // multiple times gives you the same thing.
  331. // Otherwise, our tests wouldn't work!
  332. assertSame(wb.getFontAt(0), wb.getFontAt(0));
  333. assertEquals(
  334. wb.getFontAt(0),
  335. wb.getFontAt(0)
  336. );
  337. // Look for a new font we have
  338. // yet to add
  339. assertNull(
  340. wb.findFont(
  341. false, IndexedColors.INDIGO.getIndex(), (short) 22,
  342. "Thingy", false, true, (short) 2, (byte) 2
  343. )
  344. );
  345. assertNull(
  346. wb.getStylesSource().findFont(
  347. false, new XSSFColor(IndexedColors.INDIGO, new DefaultIndexedColorMap()), (short) 22,
  348. "Thingy", false, true, (short) 2, (byte) 2
  349. )
  350. );
  351. XSSFFont nf = wb.createFont();
  352. assertEquals(2, wb.getNumberOfFonts());
  353. assertEquals(1, nf.getIndex());
  354. assertEquals(nf, wb.getFontAt(1));
  355. nf.setBold(false);
  356. nf.setColor(IndexedColors.INDIGO.getIndex());
  357. nf.setFontHeight((short) 22);
  358. nf.setFontName("Thingy");
  359. nf.setItalic(false);
  360. nf.setStrikeout(true);
  361. nf.setTypeOffset((short) 2);
  362. nf.setUnderline((byte) 2);
  363. assertEquals(2, wb.getNumberOfFonts());
  364. assertEquals(nf, wb.getFontAt(1));
  365. assertNotSame(wb.getFontAt(0), wb.getFontAt(1));
  366. // Find it now
  367. assertNotNull(
  368. wb.findFont(
  369. false, IndexedColors.INDIGO.getIndex(), (short) 22,
  370. "Thingy", false, true, (short) 2, (byte) 2
  371. )
  372. );
  373. assertNotNull(
  374. wb.getStylesSource().findFont(
  375. false, new XSSFColor(IndexedColors.INDIGO, new DefaultIndexedColorMap()), (short) 22,
  376. "Thingy", false, true, (short) 2, (byte) 2
  377. )
  378. );
  379. XSSFFont font = wb.findFont(
  380. false, IndexedColors.INDIGO.getIndex(), (short) 22,
  381. "Thingy", false, true, (short) 2, (byte) 2
  382. );
  383. assertNotNull(font);
  384. assertEquals(
  385. 1,
  386. font.getIndex()
  387. );
  388. assertEquals(nf,
  389. wb.findFont(
  390. false, IndexedColors.INDIGO.getIndex(), (short) 22,
  391. "Thingy", false, true, (short) 2, (byte) 2
  392. )
  393. );
  394. assertEquals(nf,
  395. wb.getStylesSource().findFont(
  396. false, new XSSFColor(IndexedColors.INDIGO, new DefaultIndexedColorMap()), (short) 22,
  397. "Thingy", false, true, (short) 2, (byte) 2
  398. )
  399. );
  400. }
  401. }
  402. @Test
  403. void testEquals() {
  404. XSSFFont font = new XSSFFont();
  405. XSSFFont equ = new XSSFFont();
  406. XSSFFont notequ = new XSSFFont();
  407. notequ.setItalic(true);
  408. assertEquals(equ, font);
  409. assertNotEquals(font, notequ);
  410. notequ.setItalic(false);
  411. notequ.setThemeColor((short)123);
  412. assertNotEquals(font, notequ);
  413. }
  414. @Test
  415. public void testBug62272() throws IOException {
  416. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("62272.xlsx")) {
  417. // make sure we read the font-color with alpha
  418. checkFontColor(wb);
  419. }
  420. }
  421. @Test
  422. public void testBug62272a() throws IOException {
  423. try (XSSFWorkbook wb = new XSSFWorkbook()) {
  424. Sheet sheet = wb.createSheet("test");
  425. Row row = sheet.createRow(0);
  426. Cell cell = row.createCell(0);
  427. // create a font with alpha
  428. XSSFFont font = wb.createFont();
  429. font.setColor(new XSSFColor(new byte[] {
  430. 0x7f, 0x33, (byte)0xCC, 0x66
  431. }));
  432. XSSFCellStyle style = wb.createCellStyle();
  433. style.setFont(font);
  434. cell.setCellStyle(style);
  435. cell.setCellValue("testtext");
  436. // make sure the alpha-value was stored properly
  437. checkFontColor(wb);
  438. /*try (OutputStream out = new FileOutputStream("/tmp/testout.xlsx")) {
  439. wb.write(out);
  440. }*/
  441. }
  442. }
  443. private static void checkFontColor(Workbook wb) {
  444. int fontIdx = wb.getSheetAt(0).getRow(0).getCell(0).getCellStyle().getFontIndex();
  445. Font font = wb.getFontAt(fontIdx);
  446. //System.out.println(font.getColor());
  447. CTColor[] colorArray = ((XSSFFont) font).getCTFont().getColorArray();
  448. //System.out.println(Arrays.toString(colorArray));
  449. assertArrayEquals(new byte[] {
  450. 0x7f, 0x33, (byte)0xCC, 0x66
  451. }, colorArray[0].getRgb());
  452. }
  453. }