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.

TestXSSFCellStyle.java 39KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  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 java.io.IOException;
  17. import junit.framework.TestCase;
  18. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  19. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  20. import org.apache.poi.ss.usermodel.CellStyle;
  21. import org.apache.poi.ss.usermodel.HorizontalAlignment;
  22. import org.apache.poi.ss.usermodel.IndexedColors;
  23. import org.apache.poi.ss.usermodel.Row;
  24. import org.apache.poi.ss.usermodel.Sheet;
  25. import org.apache.poi.ss.usermodel.VerticalAlignment;
  26. import org.apache.poi.xssf.XSSFTestDataSamples;
  27. import org.apache.poi.xssf.model.StylesTable;
  28. import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
  29. import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
  30. import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
  31. public class TestXSSFCellStyle extends TestCase {
  32. private StylesTable stylesTable;
  33. private CTBorder ctBorderA;
  34. private CTFill ctFill;
  35. private CTFont ctFont;
  36. private CTXf cellStyleXf;
  37. private CTXf cellXf;
  38. private CTCellXfs cellXfs;
  39. private XSSFCellStyle cellStyle;
  40. private CTStylesheet ctStylesheet;
  41. @Override
  42. protected void setUp() {
  43. stylesTable = new StylesTable();
  44. ctStylesheet = stylesTable.getCTStylesheet();
  45. ctBorderA = CTBorder.Factory.newInstance();
  46. XSSFCellBorder borderA = new XSSFCellBorder(ctBorderA);
  47. long borderId = stylesTable.putBorder(borderA);
  48. assertEquals(1, borderId);
  49. XSSFCellBorder borderB = new XSSFCellBorder();
  50. assertEquals(1, stylesTable.putBorder(borderB));
  51. ctFill = CTFill.Factory.newInstance();
  52. XSSFCellFill fill = new XSSFCellFill(ctFill);
  53. long fillId = stylesTable.putFill(fill);
  54. assertEquals(2, fillId);
  55. ctFont = CTFont.Factory.newInstance();
  56. XSSFFont font = new XSSFFont(ctFont);
  57. long fontId = stylesTable.putFont(font);
  58. assertEquals(1, fontId);
  59. cellStyleXf = ctStylesheet.addNewCellStyleXfs().addNewXf();
  60. cellStyleXf.setBorderId(1);
  61. cellStyleXf.setFillId(1);
  62. cellStyleXf.setFontId(1);
  63. cellXfs = ctStylesheet.addNewCellXfs();
  64. cellXf = cellXfs.addNewXf();
  65. cellXf.setXfId(1);
  66. cellXf.setBorderId(1);
  67. cellXf.setFillId(1);
  68. cellXf.setFontId(1);
  69. stylesTable.putCellStyleXf(cellStyleXf);
  70. stylesTable.putCellXf(cellXf);
  71. cellStyle = new XSSFCellStyle(1, 1, stylesTable, null);
  72. assertNotNull(stylesTable.getFillAt(1).getCTFill().getPatternFill());
  73. assertEquals(STPatternType.INT_DARK_GRAY, stylesTable.getFillAt(1).getCTFill().getPatternFill().getPatternType().intValue());
  74. }
  75. public void testGetSetBorderBottom() {
  76. //default values
  77. assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderBottom());
  78. int num = stylesTable.getBorders().size();
  79. cellStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);
  80. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderBottom());
  81. //a new border has been added
  82. assertEquals(num + 1, stylesTable.getBorders().size());
  83. //id of the created border
  84. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  85. assertTrue(borderId > 0);
  86. //check changes in the underlying xml bean
  87. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  88. assertEquals(STBorderStyle.MEDIUM, ctBorder.getBottom().getStyle());
  89. num = stylesTable.getBorders().size();
  90. //setting the same border multiple times should not change borderId
  91. for (int i = 0; i < 3; i++) {
  92. cellStyle.setBorderBottom(CellStyle.BORDER_MEDIUM);
  93. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderBottom());
  94. }
  95. assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
  96. assertEquals(num, stylesTable.getBorders().size());
  97. assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
  98. //setting border to none removes the <bottom> element
  99. cellStyle.setBorderBottom(CellStyle.BORDER_NONE);
  100. assertEquals(num, stylesTable.getBorders().size());
  101. borderId = (int)cellStyle.getCoreXf().getBorderId();
  102. ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  103. assertFalse(ctBorder.isSetBottom());
  104. }
  105. public void testGetSetBorderRight() {
  106. //default values
  107. assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderRight());
  108. int num = stylesTable.getBorders().size();
  109. cellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
  110. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderRight());
  111. //a new border has been added
  112. assertEquals(num + 1, stylesTable.getBorders().size());
  113. //id of the created border
  114. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  115. assertTrue(borderId > 0);
  116. //check changes in the underlying xml bean
  117. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  118. assertEquals(STBorderStyle.MEDIUM, ctBorder.getRight().getStyle());
  119. num = stylesTable.getBorders().size();
  120. //setting the same border multiple times should not change borderId
  121. for (int i = 0; i < 3; i++) {
  122. cellStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
  123. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderRight());
  124. }
  125. assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
  126. assertEquals(num, stylesTable.getBorders().size());
  127. assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
  128. //setting border to none removes the <right> element
  129. cellStyle.setBorderRight(CellStyle.BORDER_NONE);
  130. assertEquals(num, stylesTable.getBorders().size());
  131. borderId = (int)cellStyle.getCoreXf().getBorderId();
  132. ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  133. assertFalse(ctBorder.isSetRight());
  134. }
  135. public void testGetSetBorderLeft() {
  136. //default values
  137. assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderLeft());
  138. int num = stylesTable.getBorders().size();
  139. cellStyle.setBorderLeft(CellStyle.BORDER_MEDIUM);
  140. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderLeft());
  141. //a new border has been added
  142. assertEquals(num + 1, stylesTable.getBorders().size());
  143. //id of the created border
  144. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  145. assertTrue(borderId > 0);
  146. //check changes in the underlying xml bean
  147. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  148. assertEquals(STBorderStyle.MEDIUM, ctBorder.getLeft().getStyle());
  149. num = stylesTable.getBorders().size();
  150. //setting the same border multiple times should not change borderId
  151. for (int i = 0; i < 3; i++) {
  152. cellStyle.setBorderLeft(CellStyle.BORDER_MEDIUM);
  153. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderLeft());
  154. }
  155. assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
  156. assertEquals(num, stylesTable.getBorders().size());
  157. assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
  158. //setting border to none removes the <left> element
  159. cellStyle.setBorderLeft(CellStyle.BORDER_NONE);
  160. assertEquals(num, stylesTable.getBorders().size());
  161. borderId = (int)cellStyle.getCoreXf().getBorderId();
  162. ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  163. assertFalse(ctBorder.isSetLeft());
  164. }
  165. public void testGetSetBorderTop() {
  166. //default values
  167. assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderTop());
  168. int num = stylesTable.getBorders().size();
  169. cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
  170. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
  171. //a new border has been added
  172. assertEquals(num + 1, stylesTable.getBorders().size());
  173. //id of the created border
  174. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  175. assertTrue(borderId > 0);
  176. //check changes in the underlying xml bean
  177. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  178. assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
  179. num = stylesTable.getBorders().size();
  180. //setting the same border multiple times should not change borderId
  181. for (int i = 0; i < 3; i++) {
  182. cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
  183. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
  184. }
  185. assertEquals(borderId, cellStyle.getCoreXf().getBorderId());
  186. assertEquals(num, stylesTable.getBorders().size());
  187. assertSame(ctBorder, stylesTable.getBorderAt(borderId).getCTBorder());
  188. //setting border to none removes the <top> element
  189. cellStyle.setBorderTop(CellStyle.BORDER_NONE);
  190. assertEquals(num, stylesTable.getBorders().size());
  191. borderId = (int)cellStyle.getCoreXf().getBorderId();
  192. ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  193. assertFalse(ctBorder.isSetTop());
  194. }
  195. public void testGetSetBorderThin() {
  196. cellStyle.setBorderTop(CellStyle.BORDER_THIN);
  197. assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
  198. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  199. assertTrue(borderId > 0);
  200. //check changes in the underlying xml bean
  201. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  202. assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
  203. }
  204. public void testGetSetBorderMedium() {
  205. cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
  206. assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
  207. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  208. assertTrue(borderId > 0);
  209. //check changes in the underlying xml bean
  210. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  211. assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
  212. }
  213. public void testGetSetBorderThick() {
  214. cellStyle.setBorderTop(CellStyle.BORDER_THICK);
  215. assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
  216. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  217. assertTrue(borderId > 0);
  218. //check changes in the underlying xml bean
  219. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  220. assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
  221. }
  222. public void testGetSetBorderHair() {
  223. cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
  224. assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
  225. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  226. assertTrue(borderId > 0);
  227. //check changes in the underlying xml bean
  228. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  229. assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
  230. }
  231. public void testGetSetBorderDotted() {
  232. cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
  233. assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
  234. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  235. assertTrue(borderId > 0);
  236. //check changes in the underlying xml bean
  237. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  238. assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
  239. }
  240. public void testGetSetBorderDashed() {
  241. cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
  242. assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
  243. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  244. assertTrue(borderId > 0);
  245. //check changes in the underlying xml bean
  246. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  247. assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
  248. }
  249. public void testGetSetBorderDashDot() {
  250. cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
  251. assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
  252. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  253. assertTrue(borderId > 0);
  254. //check changes in the underlying xml bean
  255. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  256. assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
  257. }
  258. public void testGetSetBorderDashDotDot() {
  259. cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
  260. assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
  261. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  262. assertTrue(borderId > 0);
  263. //check changes in the underlying xml bean
  264. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  265. assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
  266. }
  267. public void testGetSetBorderMediumDashDot() {
  268. cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
  269. assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
  270. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  271. assertTrue(borderId > 0);
  272. //check changes in the underlying xml bean
  273. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  274. assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
  275. }
  276. public void testGetSetBorderMediumDashDotDot() {
  277. cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
  278. assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
  279. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  280. assertTrue(borderId > 0);
  281. //check changes in the underlying xml bean
  282. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  283. assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
  284. }
  285. public void testGetSetBorderMediumDashed() {
  286. cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
  287. assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
  288. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  289. assertTrue(borderId > 0);
  290. //check changes in the underlying xml bean
  291. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  292. assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
  293. }
  294. public void testGetSetBorderSlantDashDot() {
  295. cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
  296. assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
  297. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  298. assertTrue(borderId > 0);
  299. //check changes in the underlying xml bean
  300. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  301. assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
  302. }
  303. public void testGetSetBorderDouble() {
  304. cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
  305. assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
  306. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  307. assertTrue(borderId > 0);
  308. //check changes in the underlying xml bean
  309. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  310. assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
  311. }
  312. public void testGetSetBottomBorderColor() {
  313. //defaults
  314. assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
  315. assertNull(cellStyle.getBottomBorderXSSFColor());
  316. int num = stylesTable.getBorders().size();
  317. XSSFColor clr;
  318. //setting indexed color
  319. cellStyle.setBottomBorderColor(IndexedColors.BLUE_GREY.getIndex());
  320. assertEquals(IndexedColors.BLUE_GREY.getIndex(), cellStyle.getBottomBorderColor());
  321. clr = cellStyle.getBottomBorderXSSFColor();
  322. assertTrue(clr.getCTColor().isSetIndexed());
  323. assertEquals(IndexedColors.BLUE_GREY.getIndex(), clr.getIndexed());
  324. //a new border was added to the styles table
  325. assertEquals(num + 1, stylesTable.getBorders().size());
  326. //id of the created border
  327. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  328. assertTrue(borderId > 0);
  329. //check changes in the underlying xml bean
  330. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  331. assertEquals(IndexedColors.BLUE_GREY.getIndex(), ctBorder.getBottom().getColor().getIndexed());
  332. //setting XSSFColor
  333. num = stylesTable.getBorders().size();
  334. clr = new XSSFColor(java.awt.Color.CYAN);
  335. cellStyle.setBottomBorderColor(clr);
  336. assertEquals(clr.getCTColor().toString(), cellStyle.getBottomBorderXSSFColor().getCTColor().toString());
  337. byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRgb();
  338. assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
  339. //another border was added to the styles table
  340. assertEquals(num + 1, stylesTable.getBorders().size());
  341. //passing null unsets the color
  342. cellStyle.setBottomBorderColor(null);
  343. assertNull(cellStyle.getBottomBorderXSSFColor());
  344. }
  345. public void testGetSetTopBorderColor() {
  346. //defaults
  347. assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getTopBorderColor());
  348. assertNull(cellStyle.getTopBorderXSSFColor());
  349. int num = stylesTable.getBorders().size();
  350. XSSFColor clr;
  351. //setting indexed color
  352. cellStyle.setTopBorderColor(IndexedColors.BLUE_GREY.getIndex());
  353. assertEquals(IndexedColors.BLUE_GREY.getIndex(), cellStyle.getTopBorderColor());
  354. clr = cellStyle.getTopBorderXSSFColor();
  355. assertTrue(clr.getCTColor().isSetIndexed());
  356. assertEquals(IndexedColors.BLUE_GREY.getIndex(), clr.getIndexed());
  357. //a new border was added to the styles table
  358. assertEquals(num + 1, stylesTable.getBorders().size());
  359. //id of the created border
  360. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  361. assertTrue(borderId > 0);
  362. //check changes in the underlying xml bean
  363. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  364. assertEquals(IndexedColors.BLUE_GREY.getIndex(), ctBorder.getTop().getColor().getIndexed());
  365. //setting XSSFColor
  366. num = stylesTable.getBorders().size();
  367. clr = new XSSFColor(java.awt.Color.CYAN);
  368. cellStyle.setTopBorderColor(clr);
  369. assertEquals(clr.getCTColor().toString(), cellStyle.getTopBorderXSSFColor().getCTColor().toString());
  370. byte[] rgb = cellStyle.getTopBorderXSSFColor().getRgb();
  371. assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
  372. //another border was added to the styles table
  373. assertEquals(num + 1, stylesTable.getBorders().size());
  374. //passing null unsets the color
  375. cellStyle.setTopBorderColor(null);
  376. assertNull(cellStyle.getTopBorderXSSFColor());
  377. }
  378. public void testGetSetLeftBorderColor() {
  379. //defaults
  380. assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getLeftBorderColor());
  381. assertNull(cellStyle.getLeftBorderXSSFColor());
  382. int num = stylesTable.getBorders().size();
  383. XSSFColor clr;
  384. //setting indexed color
  385. cellStyle.setLeftBorderColor(IndexedColors.BLUE_GREY.getIndex());
  386. assertEquals(IndexedColors.BLUE_GREY.getIndex(), cellStyle.getLeftBorderColor());
  387. clr = cellStyle.getLeftBorderXSSFColor();
  388. assertTrue(clr.getCTColor().isSetIndexed());
  389. assertEquals(IndexedColors.BLUE_GREY.getIndex(), clr.getIndexed());
  390. //a new border was added to the styles table
  391. assertEquals(num + 1, stylesTable.getBorders().size());
  392. //id of the created border
  393. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  394. assertTrue(borderId > 0);
  395. //check changes in the underlying xml bean
  396. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  397. assertEquals(IndexedColors.BLUE_GREY.getIndex(), ctBorder.getLeft().getColor().getIndexed());
  398. //setting XSSFColor
  399. num = stylesTable.getBorders().size();
  400. clr = new XSSFColor(java.awt.Color.CYAN);
  401. cellStyle.setLeftBorderColor(clr);
  402. assertEquals(clr.getCTColor().toString(), cellStyle.getLeftBorderXSSFColor().getCTColor().toString());
  403. byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRgb();
  404. assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
  405. //another border was added to the styles table
  406. assertEquals(num + 1, stylesTable.getBorders().size());
  407. //passing null unsets the color
  408. cellStyle.setLeftBorderColor(null);
  409. assertNull(cellStyle.getLeftBorderXSSFColor());
  410. }
  411. public void testGetSetRightBorderColor() {
  412. //defaults
  413. assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getRightBorderColor());
  414. assertNull(cellStyle.getRightBorderXSSFColor());
  415. int num = stylesTable.getBorders().size();
  416. XSSFColor clr;
  417. //setting indexed color
  418. cellStyle.setRightBorderColor(IndexedColors.BLUE_GREY.getIndex());
  419. assertEquals(IndexedColors.BLUE_GREY.getIndex(), cellStyle.getRightBorderColor());
  420. clr = cellStyle.getRightBorderXSSFColor();
  421. assertTrue(clr.getCTColor().isSetIndexed());
  422. assertEquals(IndexedColors.BLUE_GREY.getIndex(), clr.getIndexed());
  423. //a new border was added to the styles table
  424. assertEquals(num + 1, stylesTable.getBorders().size());
  425. //id of the created border
  426. int borderId = (int)cellStyle.getCoreXf().getBorderId();
  427. assertTrue(borderId > 0);
  428. //check changes in the underlying xml bean
  429. CTBorder ctBorder = stylesTable.getBorderAt(borderId).getCTBorder();
  430. assertEquals(IndexedColors.BLUE_GREY.getIndex(), ctBorder.getRight().getColor().getIndexed());
  431. //setting XSSFColor
  432. num = stylesTable.getBorders().size();
  433. clr = new XSSFColor(java.awt.Color.CYAN);
  434. cellStyle.setRightBorderColor(clr);
  435. assertEquals(clr.getCTColor().toString(), cellStyle.getRightBorderXSSFColor().getCTColor().toString());
  436. byte[] rgb = cellStyle.getRightBorderXSSFColor().getRgb();
  437. assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
  438. //another border was added to the styles table
  439. assertEquals(num + 1, stylesTable.getBorders().size());
  440. //passing null unsets the color
  441. cellStyle.setRightBorderColor(null);
  442. assertNull(cellStyle.getRightBorderXSSFColor());
  443. }
  444. public void testGetSetFillBackgroundColor() {
  445. assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
  446. assertNull(cellStyle.getFillBackgroundXSSFColor());
  447. XSSFColor clr;
  448. int num = stylesTable.getFills().size();
  449. //setting indexed color
  450. cellStyle.setFillBackgroundColor(IndexedColors.RED.getIndex());
  451. assertEquals(IndexedColors.RED.getIndex(), cellStyle.getFillBackgroundColor());
  452. clr = cellStyle.getFillBackgroundXSSFColor();
  453. assertTrue(clr.getCTColor().isSetIndexed());
  454. assertEquals(IndexedColors.RED.getIndex(), clr.getIndexed());
  455. //a new fill was added to the styles table
  456. assertEquals(num + 1, stylesTable.getFills().size());
  457. //id of the created border
  458. int fillId = (int)cellStyle.getCoreXf().getFillId();
  459. assertTrue(fillId > 0);
  460. //check changes in the underlying xml bean
  461. CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
  462. assertEquals(IndexedColors.RED.getIndex(), ctFill.getPatternFill().getBgColor().getIndexed());
  463. //setting XSSFColor
  464. num = stylesTable.getFills().size();
  465. clr = new XSSFColor(java.awt.Color.CYAN);
  466. cellStyle.setFillBackgroundColor(clr);
  467. assertEquals(clr.getCTColor().toString(), cellStyle.getFillBackgroundXSSFColor().getCTColor().toString());
  468. byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRgb();
  469. assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
  470. //another border was added to the styles table
  471. assertEquals(num + 1, stylesTable.getFills().size());
  472. //passing null unsets the color
  473. cellStyle.setFillBackgroundColor(null);
  474. assertNull(cellStyle.getFillBackgroundXSSFColor());
  475. assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
  476. }
  477. public void testDefaultStyles() throws IOException {
  478. XSSFWorkbook wb1 = new XSSFWorkbook();
  479. XSSFCellStyle style1 = wb1.createCellStyle();
  480. assertEquals(IndexedColors.AUTOMATIC.getIndex(), style1.getFillBackgroundColor());
  481. assertNull(style1.getFillBackgroundXSSFColor());
  482. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb1));
  483. //compatibility with HSSF
  484. HSSFWorkbook wb2 = new HSSFWorkbook();
  485. HSSFCellStyle style2 = wb2.createCellStyle();
  486. assertEquals(style2.getFillBackgroundColor(), style1.getFillBackgroundColor());
  487. assertEquals(style2.getFillForegroundColor(), style1.getFillForegroundColor());
  488. assertEquals(style2.getFillPattern(), style1.getFillPattern());
  489. assertEquals(style2.getLeftBorderColor(), style1.getLeftBorderColor());
  490. assertEquals(style2.getTopBorderColor(), style1.getTopBorderColor());
  491. assertEquals(style2.getRightBorderColor(), style1.getRightBorderColor());
  492. assertEquals(style2.getBottomBorderColor(), style1.getBottomBorderColor());
  493. assertEquals(style2.getBorderBottom(), style1.getBorderBottom());
  494. assertEquals(style2.getBorderLeft(), style1.getBorderLeft());
  495. assertEquals(style2.getBorderRight(), style1.getBorderRight());
  496. assertEquals(style2.getBorderTop(), style1.getBorderTop());
  497. wb2.close();
  498. }
  499. public void testGetFillForegroundColor() {
  500. XSSFWorkbook wb = new XSSFWorkbook();
  501. StylesTable styles = wb.getStylesSource();
  502. assertEquals(1, wb.getNumCellStyles());
  503. assertEquals(2, styles.getFills().size());
  504. XSSFCellStyle defaultStyle = wb.getCellStyleAt((short)0);
  505. assertEquals(IndexedColors.AUTOMATIC.getIndex(), defaultStyle.getFillForegroundColor());
  506. assertEquals(null, defaultStyle.getFillForegroundXSSFColor());
  507. assertEquals(CellStyle.NO_FILL, defaultStyle.getFillPattern());
  508. XSSFCellStyle customStyle = wb.createCellStyle();
  509. customStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
  510. assertEquals(CellStyle.SOLID_FOREGROUND, customStyle.getFillPattern());
  511. assertEquals(3, styles.getFills().size());
  512. customStyle.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
  513. assertEquals(IndexedColors.BRIGHT_GREEN.getIndex(), customStyle.getFillForegroundColor());
  514. assertEquals(4, styles.getFills().size());
  515. for (int i = 0; i < 3; i++) {
  516. XSSFCellStyle style = wb.createCellStyle();
  517. style.setFillPattern(CellStyle.SOLID_FOREGROUND);
  518. assertEquals(CellStyle.SOLID_FOREGROUND, style.getFillPattern());
  519. assertEquals(4, styles.getFills().size());
  520. style.setFillForegroundColor(IndexedColors.BRIGHT_GREEN.getIndex());
  521. assertEquals(IndexedColors.BRIGHT_GREEN.getIndex(), style.getFillForegroundColor());
  522. assertEquals(4, styles.getFills().size());
  523. }
  524. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
  525. }
  526. public void testGetFillPattern() {
  527. assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPattern());
  528. int num = stylesTable.getFills().size();
  529. cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
  530. assertEquals(CellStyle.SOLID_FOREGROUND, cellStyle.getFillPattern());
  531. assertEquals(num + 1, stylesTable.getFills().size());
  532. int fillId = (int)cellStyle.getCoreXf().getFillId();
  533. assertTrue(fillId > 0);
  534. //check changes in the underlying xml bean
  535. CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
  536. assertEquals(STPatternType.SOLID, ctFill.getPatternFill().getPatternType());
  537. //setting the same fill multiple time does not update the styles table
  538. for (int i = 0; i < 3; i++) {
  539. cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
  540. }
  541. assertEquals(num + 1, stylesTable.getFills().size());
  542. cellStyle.setFillPattern(CellStyle.NO_FILL);
  543. assertEquals(CellStyle.NO_FILL, cellStyle.getFillPattern());
  544. fillId = (int)cellStyle.getCoreXf().getFillId();
  545. ctFill = stylesTable.getFillAt(fillId).getCTFill();
  546. assertFalse(ctFill.getPatternFill().isSetPatternType());
  547. }
  548. public void testGetFont() {
  549. assertNotNull(cellStyle.getFont());
  550. }
  551. public void testGetSetHidden() {
  552. assertFalse(cellStyle.getHidden());
  553. cellStyle.setHidden(true);
  554. assertTrue(cellStyle.getHidden());
  555. cellStyle.setHidden(false);
  556. assertFalse(cellStyle.getHidden());
  557. }
  558. public void testGetSetLocked() {
  559. assertTrue(cellStyle.getLocked());
  560. cellStyle.setLocked(true);
  561. assertTrue(cellStyle.getLocked());
  562. cellStyle.setLocked(false);
  563. assertFalse(cellStyle.getLocked());
  564. }
  565. public void testGetSetIndent() {
  566. assertEquals((short)0, cellStyle.getIndention());
  567. cellStyle.setIndention((short)3);
  568. assertEquals((short)3, cellStyle.getIndention());
  569. cellStyle.setIndention((short) 13);
  570. assertEquals((short)13, cellStyle.getIndention());
  571. }
  572. public void testGetSetAlignement() {
  573. assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
  574. assertEquals(HorizontalAlignment.GENERAL, cellStyle.getAlignmentEnum());
  575. cellStyle.setAlignment(XSSFCellStyle.ALIGN_LEFT);
  576. assertEquals(XSSFCellStyle.ALIGN_LEFT, cellStyle.getAlignment());
  577. assertEquals(HorizontalAlignment.LEFT, cellStyle.getAlignmentEnum());
  578. assertEquals(STHorizontalAlignment.LEFT, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
  579. cellStyle.setAlignment(HorizontalAlignment.JUSTIFY);
  580. assertEquals(XSSFCellStyle.ALIGN_JUSTIFY, cellStyle.getAlignment());
  581. assertEquals(HorizontalAlignment.JUSTIFY, cellStyle.getAlignmentEnum());
  582. assertEquals(STHorizontalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
  583. cellStyle.setAlignment(HorizontalAlignment.CENTER);
  584. assertEquals(XSSFCellStyle.ALIGN_CENTER, cellStyle.getAlignment());
  585. assertEquals(HorizontalAlignment.CENTER, cellStyle.getAlignmentEnum());
  586. assertEquals(STHorizontalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
  587. }
  588. public void testGetSetVerticalAlignment() {
  589. assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignmentEnum());
  590. assertEquals(XSSFCellStyle.VERTICAL_BOTTOM, cellStyle.getVerticalAlignment());
  591. assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
  592. cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
  593. assertEquals(XSSFCellStyle.VERTICAL_CENTER, cellStyle.getVerticalAlignment());
  594. assertEquals(VerticalAlignment.CENTER, cellStyle.getVerticalAlignmentEnum());
  595. assertEquals(STVerticalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
  596. cellStyle.setVerticalAlignment(XSSFCellStyle.VERTICAL_JUSTIFY);
  597. assertEquals(XSSFCellStyle.VERTICAL_JUSTIFY, cellStyle.getVerticalAlignment());
  598. assertEquals(VerticalAlignment.JUSTIFY, cellStyle.getVerticalAlignmentEnum());
  599. assertEquals(STVerticalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
  600. }
  601. public void testGetSetWrapText() {
  602. assertFalse(cellStyle.getWrapText());
  603. cellStyle.setWrapText(true);
  604. assertTrue(cellStyle.getWrapText());
  605. cellStyle.setWrapText(false);
  606. assertFalse(cellStyle.getWrapText());
  607. }
  608. /**
  609. * Cloning one XSSFCellStyle onto Another, same XSSFWorkbook
  610. */
  611. public void testCloneStyleSameWB() {
  612. XSSFWorkbook wb = new XSSFWorkbook();
  613. assertEquals(1, wb.getNumberOfFonts());
  614. XSSFFont fnt = wb.createFont();
  615. fnt.setFontName("TestingFont");
  616. assertEquals(2, wb.getNumberOfFonts());
  617. XSSFCellStyle orig = wb.createCellStyle();
  618. orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
  619. orig.setFont(fnt);
  620. orig.setDataFormat((short)18);
  621. assertTrue(HSSFCellStyle.ALIGN_RIGHT == orig.getAlignment());
  622. assertTrue(fnt == orig.getFont());
  623. assertTrue(18 == orig.getDataFormat());
  624. XSSFCellStyle clone = wb.createCellStyle();
  625. assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
  626. assertFalse(fnt == clone.getFont());
  627. assertFalse(18 == clone.getDataFormat());
  628. clone.cloneStyleFrom(orig);
  629. assertTrue(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
  630. assertTrue(fnt == clone.getFont());
  631. assertTrue(18 == clone.getDataFormat());
  632. assertEquals(2, wb.getNumberOfFonts());
  633. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
  634. }
  635. /**
  636. * Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks
  637. */
  638. public void testCloneStyleDiffWB() {
  639. XSSFWorkbook wbOrig = new XSSFWorkbook();
  640. assertEquals(1, wbOrig.getNumberOfFonts());
  641. assertEquals(0, wbOrig.getStylesSource().getNumberFormats().size());
  642. XSSFFont fnt = wbOrig.createFont();
  643. fnt.setFontName("TestingFont");
  644. assertEquals(2, wbOrig.getNumberOfFonts());
  645. assertEquals(0, wbOrig.getStylesSource().getNumberFormats().size());
  646. XSSFDataFormat fmt = wbOrig.createDataFormat();
  647. fmt.getFormat("MadeUpOne");
  648. fmt.getFormat("MadeUpTwo");
  649. XSSFCellStyle orig = wbOrig.createCellStyle();
  650. orig.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
  651. orig.setFont(fnt);
  652. orig.setDataFormat(fmt.getFormat("Test##"));
  653. assertTrue(XSSFCellStyle.ALIGN_RIGHT == orig.getAlignment());
  654. assertTrue(fnt == orig.getFont());
  655. assertTrue(fmt.getFormat("Test##") == orig.getDataFormat());
  656. assertEquals(2, wbOrig.getNumberOfFonts());
  657. assertEquals(3, wbOrig.getStylesSource().getNumberFormats().size());
  658. // Now a style on another workbook
  659. XSSFWorkbook wbClone = new XSSFWorkbook();
  660. assertEquals(1, wbClone.getNumberOfFonts());
  661. assertEquals(0, wbClone.getStylesSource().getNumberFormats().size());
  662. assertEquals(1, wbClone.getNumCellStyles());
  663. XSSFDataFormat fmtClone = wbClone.createDataFormat();
  664. XSSFCellStyle clone = wbClone.createCellStyle();
  665. assertEquals(1, wbClone.getNumberOfFonts());
  666. assertEquals(0, wbClone.getStylesSource().getNumberFormats().size());
  667. assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
  668. assertFalse("TestingFont" == clone.getFont().getFontName());
  669. clone.cloneStyleFrom(orig);
  670. assertEquals(2, wbClone.getNumberOfFonts());
  671. assertEquals(2, wbClone.getNumCellStyles());
  672. assertEquals(1, wbClone.getStylesSource().getNumberFormats().size());
  673. assertEquals(HSSFCellStyle.ALIGN_RIGHT, clone.getAlignment());
  674. assertEquals("TestingFont", clone.getFont().getFontName());
  675. assertEquals(fmtClone.getFormat("Test##"), clone.getDataFormat());
  676. assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
  677. // Save it and re-check
  678. XSSFWorkbook wbReload = XSSFTestDataSamples.writeOutAndReadBack(wbClone);
  679. assertEquals(2, wbReload.getNumberOfFonts());
  680. assertEquals(2, wbReload.getNumCellStyles());
  681. assertEquals(1, wbReload.getStylesSource().getNumberFormats().size());
  682. XSSFCellStyle reload = wbReload.getCellStyleAt((short)1);
  683. assertEquals(HSSFCellStyle.ALIGN_RIGHT, reload.getAlignment());
  684. assertEquals("TestingFont", reload.getFont().getFontName());
  685. assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
  686. assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
  687. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
  688. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbClone));
  689. }
  690. /**
  691. * Avoid ArrayIndexOutOfBoundsException when creating cell style
  692. * in a workbook that has an empty xf table.
  693. */
  694. public void testBug52348() {
  695. XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
  696. StylesTable st = workbook.getStylesSource();
  697. assertEquals(0, st._getStyleXfsSize());
  698. XSSFCellStyle style = workbook.createCellStyle(); // no exception at this point
  699. assertNull(style.getStyleXf());
  700. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
  701. }
  702. /**
  703. * Avoid ArrayIndexOutOfBoundsException when getting cell style
  704. * in a workbook that has an empty xf table.
  705. */
  706. public void testBug55650() {
  707. XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
  708. StylesTable st = workbook.getStylesSource();
  709. assertEquals(0, st._getStyleXfsSize());
  710. // no exception at this point
  711. XSSFCellStyle style = workbook.getSheetAt(0).getRow(0).getCell(0).getCellStyle();
  712. assertNull(style.getStyleXf());
  713. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
  714. }
  715. public void testShrinkToFit() {
  716. // Existing file
  717. XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
  718. Sheet s = wb.getSheetAt(0);
  719. Row r = s.getRow(0);
  720. CellStyle cs = r.getCell(0).getCellStyle();
  721. assertEquals(true, cs.getShrinkToFit());
  722. // New file
  723. XSSFWorkbook wbOrig = new XSSFWorkbook();
  724. s = wbOrig.createSheet();
  725. r = s.createRow(0);
  726. cs = wbOrig.createCellStyle();
  727. cs.setShrinkToFit(false);
  728. r.createCell(0).setCellStyle(cs);
  729. cs = wbOrig.createCellStyle();
  730. cs.setShrinkToFit(true);
  731. r.createCell(1).setCellStyle(cs);
  732. // Write out, read, and check
  733. wb = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
  734. s = wb.getSheetAt(0);
  735. r = s.getRow(0);
  736. assertEquals(false, r.getCell(0).getCellStyle().getShrinkToFit());
  737. assertEquals(true, r.getCell(1).getCellStyle().getShrinkToFit());
  738. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
  739. assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
  740. }
  741. }