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.

TestXSSFSheetShiftRows.java 20KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  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.junit.jupiter.api.Assertions.assertEquals;
  17. import static org.junit.jupiter.api.Assertions.assertNotNull;
  18. import static org.junit.jupiter.api.Assertions.assertNull;
  19. import static org.junit.jupiter.api.Assertions.assertThrows;
  20. import java.io.IOException;
  21. import java.util.stream.IntStream;
  22. import org.apache.poi.ss.usermodel.BaseTestSheetShiftRows;
  23. import org.apache.poi.ss.usermodel.Cell;
  24. import org.apache.poi.ss.usermodel.CellType;
  25. import org.apache.poi.ss.usermodel.Comment;
  26. import org.apache.poi.ss.usermodel.Row;
  27. import org.apache.poi.ss.usermodel.Sheet;
  28. import org.apache.poi.ss.usermodel.Workbook;
  29. import org.apache.poi.ss.util.CellAddress;
  30. import org.apache.poi.ss.util.CellUtil;
  31. import org.apache.poi.xssf.XSSFITestDataProvider;
  32. import org.apache.poi.xssf.XSSFTestDataSamples;
  33. import org.junit.jupiter.api.Test;
  34. public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows {
  35. public TestXSSFSheetShiftRows(){
  36. super(XSSFITestDataProvider.instance);
  37. }
  38. @Override
  39. protected void testShiftRowBreaks() {
  40. // disabled test from superclass
  41. // TODO - support shifting of page breaks
  42. }
  43. /** Error occurred at FormulaShifter#rowMoveAreaPtg while shift rows upward. */
  44. @Test
  45. void testBug54524() throws IOException {
  46. XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("54524.xlsx");
  47. XSSFSheet sheet = workbook.getSheetAt(0);
  48. sheet.shiftRows(3, 5, -1);
  49. Cell cell = CellUtil.getCell(sheet.getRow(1), 0);
  50. assertEquals(1.0, cell.getNumericCellValue(), 0);
  51. cell = CellUtil.getCell(sheet.getRow(2), 0);
  52. assertEquals("SUM(A2:A2)", cell.getCellFormula());
  53. cell = CellUtil.getCell(sheet.getRow(3), 0);
  54. assertEquals("X", cell.getStringCellValue());
  55. workbook.close();
  56. }
  57. /** negative row shift causes corrupted data or throws exception */
  58. @Test
  59. void testBug53798() throws IOException {
  60. // NOTE that for HSSF (.xls) negative shifts combined with positive ones do work as expected
  61. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx");
  62. Sheet testSheet = wb.getSheetAt(0);
  63. // 1) corrupted xlsx (unreadable data in the first row of a shifted group) already comes about
  64. // when shifted by less than -1 negative amount (try -2)
  65. testSheet.shiftRows(3, 3, -2);
  66. // 2) attempt to create a new row IN PLACE of a removed row by a negative shift causes corrupted
  67. // xlsx file with unreadable data in the negative shifted row.
  68. // NOTE it's ok to create any other row.
  69. Row newRow = testSheet.createRow(3);
  70. Cell newCell = newRow.createCell(0);
  71. newCell.setCellValue("new Cell in row "+newRow.getRowNum());
  72. // 3) once a negative shift has been made any attempt to shift another group of rows
  73. // (note: outside of previously negative shifted rows) by a POSITIVE amount causes POI exception:
  74. // org.apache.xmlbeans.impl.values.XmlValueDisconnectedException.
  75. // NOTE: another negative shift on another group of rows is successful, provided no new rows in
  76. // place of previously shifted rows were attempted to be created as explained above.
  77. // -- CHANGE the shift to positive once the behaviour of the above has been tested
  78. testSheet.shiftRows(6, 7, 1);
  79. Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
  80. wb.close();
  81. assertNotNull(read);
  82. Sheet readSheet = read.getSheetAt(0);
  83. verifyCellContent(readSheet, 0, "0.0");
  84. verifyCellContent(readSheet, 1, "3.0");
  85. verifyCellContent(readSheet, 2, "2.0");
  86. verifyCellContent(readSheet, 3, "new Cell in row 3");
  87. verifyCellContent(readSheet, 4, "4.0");
  88. verifyCellContent(readSheet, 5, "5.0");
  89. verifyCellContent(readSheet, 6, null);
  90. verifyCellContent(readSheet, 7, "6.0");
  91. verifyCellContent(readSheet, 8, "7.0");
  92. read.close();
  93. }
  94. private void verifyCellContent(Sheet readSheet, int row, String expect) {
  95. Row readRow = readSheet.getRow(row);
  96. if(expect == null) {
  97. assertNull(readRow);
  98. return;
  99. }
  100. Cell readCell = readRow.getCell(0);
  101. if(readCell.getCellType() == CellType.NUMERIC) {
  102. assertEquals(expect, Double.toString(readCell.getNumericCellValue()));
  103. } else {
  104. assertEquals(expect, readCell.getStringCellValue());
  105. }
  106. }
  107. /** negative row shift causes corrupted data or throws exception */
  108. @Test
  109. void testBug53798a() throws IOException {
  110. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx");
  111. Sheet testSheet = wb.getSheetAt(0);
  112. testSheet.shiftRows(3, 3, -1);
  113. for (Row r : testSheet) {
  114. r.getRowNum();
  115. }
  116. testSheet.shiftRows(6, 6, 1);
  117. Workbook read = XSSFTestDataSamples.writeOutAndReadBack(wb);
  118. wb.close();
  119. assertNotNull(read);
  120. Sheet readSheet = read.getSheetAt(0);
  121. verifyCellContent(readSheet, 0, "0.0");
  122. verifyCellContent(readSheet, 1, "1.0");
  123. verifyCellContent(readSheet, 2, "3.0");
  124. verifyCellContent(readSheet, 3, null);
  125. verifyCellContent(readSheet, 4, "4.0");
  126. verifyCellContent(readSheet, 5, "5.0");
  127. verifyCellContent(readSheet, 6, null);
  128. verifyCellContent(readSheet, 7, "6.0");
  129. verifyCellContent(readSheet, 8, "8.0");
  130. read.close();
  131. }
  132. /** Shifting rows with comment result - Unreadable content error and comment deletion */
  133. @Test
  134. void testBug56017() throws IOException {
  135. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56017.xlsx");
  136. Sheet sheet = wb.getSheetAt(0);
  137. Comment comment = sheet.getCellComment(new CellAddress(0, 0));
  138. assertNotNull(comment);
  139. assertEquals("Amdocs", comment.getAuthor());
  140. assertEquals("Amdocs:\ntest\n", comment.getString().getString());
  141. sheet.shiftRows(0, 1, 1);
  142. // comment in row 0 is gone
  143. comment = sheet.getCellComment(new CellAddress(0, 0));
  144. assertNull(comment);
  145. // comment is now in row 1
  146. comment = sheet.getCellComment(new CellAddress(1, 0));
  147. assertNotNull(comment);
  148. assertEquals("Amdocs", comment.getAuthor());
  149. assertEquals("Amdocs:\ntest\n", comment.getString().getString());
  150. Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
  151. wb.close();
  152. assertNotNull(wbBack);
  153. Sheet sheetBack = wbBack.getSheetAt(0);
  154. // comment in row 0 is gone
  155. comment = sheetBack.getCellComment(new CellAddress(0, 0));
  156. assertNull(comment);
  157. // comment is now in row 1
  158. comment = sheetBack.getCellComment(new CellAddress(1, 0));
  159. assertNotNull(comment);
  160. assertEquals("Amdocs", comment.getAuthor());
  161. assertEquals("Amdocs:\ntest\n", comment.getString().getString());
  162. wbBack.close();
  163. }
  164. /** Moving the active sheet and deleting the others results in a corrupted file */
  165. @Test
  166. void test57171() throws IOException {
  167. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
  168. assertEquals(5, wb.getActiveSheetIndex());
  169. removeAllSheetsBut(5, wb); // 5 is the active / selected sheet
  170. assertEquals(0, wb.getActiveSheetIndex());
  171. Workbook wbRead = XSSFTestDataSamples.writeOutAndReadBack(wb);
  172. wb.close();
  173. assertEquals(0, wbRead.getActiveSheetIndex());
  174. wbRead.removeSheetAt(0);
  175. assertEquals(0, wbRead.getActiveSheetIndex());
  176. wbRead.close();
  177. }
  178. /** Cannot delete an arbitrary sheet in an XLS workbook (only the last one) */
  179. @Test
  180. void test57163() throws IOException {
  181. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
  182. assertEquals(5, wb.getActiveSheetIndex());
  183. wb.removeSheetAt(0);
  184. assertEquals(4, wb.getActiveSheetIndex());
  185. wb.close();
  186. }
  187. @Test
  188. void testSetSheetOrderAndAdjustActiveSheet() throws IOException {
  189. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
  190. assertEquals(5, wb.getActiveSheetIndex());
  191. // move the sheets around in all possible combinations to check that the active sheet
  192. // is set correctly in all cases
  193. wb.setSheetOrder(wb.getSheetName(5), 4);
  194. assertEquals(4, wb.getActiveSheetIndex());
  195. wb.setSheetOrder(wb.getSheetName(5), 5);
  196. assertEquals(4, wb.getActiveSheetIndex());
  197. wb.setSheetOrder(wb.getSheetName(3), 5);
  198. assertEquals(3, wb.getActiveSheetIndex());
  199. wb.setSheetOrder(wb.getSheetName(4), 5);
  200. assertEquals(3, wb.getActiveSheetIndex());
  201. wb.setSheetOrder(wb.getSheetName(2), 2);
  202. assertEquals(3, wb.getActiveSheetIndex());
  203. wb.setSheetOrder(wb.getSheetName(2), 1);
  204. assertEquals(3, wb.getActiveSheetIndex());
  205. wb.setSheetOrder(wb.getSheetName(3), 5);
  206. assertEquals(5, wb.getActiveSheetIndex());
  207. wb.setSheetOrder(wb.getSheetName(0), 5);
  208. assertEquals(4, wb.getActiveSheetIndex());
  209. wb.setSheetOrder(wb.getSheetName(0), 5);
  210. assertEquals(3, wb.getActiveSheetIndex());
  211. wb.setSheetOrder(wb.getSheetName(0), 5);
  212. assertEquals(2, wb.getActiveSheetIndex());
  213. wb.setSheetOrder(wb.getSheetName(0), 5);
  214. assertEquals(1, wb.getActiveSheetIndex());
  215. wb.setSheetOrder(wb.getSheetName(0), 5);
  216. assertEquals(0, wb.getActiveSheetIndex());
  217. wb.setSheetOrder(wb.getSheetName(0), 5);
  218. assertEquals(5, wb.getActiveSheetIndex());
  219. wb.close();
  220. }
  221. @Test
  222. void testRemoveSheetAndAdjustActiveSheet() throws IOException {
  223. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
  224. assertEquals(5, wb.getActiveSheetIndex());
  225. wb.removeSheetAt(0);
  226. assertEquals(4, wb.getActiveSheetIndex());
  227. wb.setActiveSheet(3);
  228. assertEquals(3, wb.getActiveSheetIndex());
  229. wb.removeSheetAt(4);
  230. assertEquals(3, wb.getActiveSheetIndex());
  231. wb.removeSheetAt(3);
  232. assertEquals(2, wb.getActiveSheetIndex());
  233. wb.removeSheetAt(0);
  234. assertEquals(1, wb.getActiveSheetIndex());
  235. wb.removeSheetAt(1);
  236. assertEquals(0, wb.getActiveSheetIndex());
  237. wb.removeSheetAt(0);
  238. assertEquals(0, wb.getActiveSheetIndex());
  239. assertThrows(IllegalArgumentException.class, () -> wb.removeSheetAt(0),
  240. "Should catch exception as no more sheets are there");
  241. assertEquals(0, wb.getActiveSheetIndex());
  242. wb.createSheet();
  243. assertEquals(0, wb.getActiveSheetIndex());
  244. wb.removeSheetAt(0);
  245. assertEquals(0, wb.getActiveSheetIndex());
  246. wb.close();
  247. }
  248. /** Failed to clone a sheet from an Excel 2010 */
  249. @Test
  250. void test57165() throws IOException {
  251. Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx");
  252. assertEquals(5, wb.getActiveSheetIndex());
  253. removeAllSheetsBut(3, wb);
  254. assertEquals(0, wb.getActiveSheetIndex());
  255. wb.createSheet("New Sheet1");
  256. assertEquals(0, wb.getActiveSheetIndex());
  257. wb.cloneSheet(0); // Throws exception here
  258. wb.setSheetName(1, "New Sheet");
  259. assertEquals(0, wb.getActiveSheetIndex());
  260. wb.close();
  261. }
  262. private static void removeAllSheetsBut(int sheetIndex, Workbook wb) {
  263. int sheetNb = wb.getNumberOfSheets();
  264. // Move this sheet at the first position
  265. wb.setSheetOrder(wb.getSheetName(sheetIndex), 0);
  266. // Must make this sheet active (otherwise, for XLSX, Excel might protest that active sheet no longer exists)
  267. // I think POI should automatically handle this case when deleting sheets...
  268. // wb.setActiveSheet(0);
  269. for (int sn = sheetNb - 1; sn > 0; sn--) {
  270. wb.removeSheetAt(sn);
  271. }
  272. }
  273. /** Shifting rows with cell comments only shifts comments from first such cell. Other cell comments not shifted */
  274. @Test
  275. void testBug57828_OnlyOneCommentShiftedInRow() throws IOException {
  276. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57828.xlsx")) {
  277. XSSFSheet sheet = wb.getSheetAt(0);
  278. Comment comment1 = sheet.getCellComment(new CellAddress(2, 1));
  279. assertNotNull(comment1);
  280. Comment comment2 = sheet.getCellComment(new CellAddress(2, 2));
  281. assertNotNull(comment2);
  282. Comment comment3 = sheet.getCellComment(new CellAddress(1, 1));
  283. assertNull(comment3, "NO comment in (1,1) and it should be null");
  284. sheet.shiftRows(2, 2, -1);
  285. comment3 = sheet.getCellComment(new CellAddress(1, 1));
  286. assertNotNull(comment3, "Comment in (2,1) moved to (1,1) so its not null now.");
  287. comment1 = sheet.getCellComment(new CellAddress(2, 1));
  288. assertNull(comment1, "No comment currently in (2,1) and hence it is null");
  289. comment2 = sheet.getCellComment(new CellAddress(1, 2));
  290. assertNotNull(comment2, "Comment in (2,2) should have moved as well because of shift rows. But its not");
  291. }
  292. }
  293. @Test
  294. void bug59733() throws IOException {
  295. Workbook workbook = new XSSFWorkbook();
  296. Sheet sheet = workbook.createSheet();
  297. for (int r=0; r<4; r++) {
  298. sheet.createRow(r);
  299. }
  300. // Shift the 2nd row on top of the 0th row
  301. sheet.shiftRows(2, 2, -2);
  302. sheet.removeRow(sheet.getRow(0));
  303. assertEquals(1, sheet.getRow(1).getRowNum());
  304. workbook.close();
  305. }
  306. private static String getCellFormula(Sheet sheet, String address) {
  307. CellAddress cellAddress = new CellAddress(address);
  308. Row row = sheet.getRow(cellAddress.getRow());
  309. assertNotNull(row);
  310. Cell cell = row.getCell(cellAddress.getColumn());
  311. assertNotNull(cell);
  312. assertEquals(CellType.FORMULA, cell.getCellType());
  313. return cell.getCellFormula();
  314. }
  315. // bug 59983: Wrong update of shared formulas after shiftRow
  316. @Test
  317. void testSharedFormulas() throws Exception {
  318. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("TestShiftRowSharedFormula.xlsx")) {
  319. XSSFSheet sheet = wb.getSheetAt(0);
  320. assertEquals("SUM(C2:C4)", getCellFormula(sheet, "C5"));
  321. assertEquals("SUM(D2:D4)", getCellFormula(sheet, "D5"));
  322. assertEquals("SUM(E2:E4)", getCellFormula(sheet, "E5"));
  323. assertEquals("SUM(C3:C5)", getCellFormula(sheet, "C6"));
  324. assertEquals("SUM(D3:D5)", getCellFormula(sheet, "D6"));
  325. assertEquals("SUM(E3:E5)", getCellFormula(sheet, "E6"));
  326. sheet.shiftRows(3, sheet.getLastRowNum(), 1);
  327. assertEquals("SUM(C2:C5)", getCellFormula(sheet, "C6"));
  328. assertEquals("SUM(D2:D5)", getCellFormula(sheet, "D6"));
  329. assertEquals("SUM(E2:E5)", getCellFormula(sheet, "E6"));
  330. assertEquals("SUM(C3:C6)", getCellFormula(sheet, "C7"));
  331. assertEquals("SUM(D3:D6)", getCellFormula(sheet, "D7"));
  332. assertEquals("SUM(E3:E6)", getCellFormula(sheet, "E7"));
  333. }
  334. }
  335. // bug 59983: Wrong update of shared formulas after shiftRow
  336. @Test
  337. void testShiftSharedFormulas() throws Exception {
  338. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("TestShiftRowSharedFormula.xlsx")) {
  339. XSSFSheet sheet = wb.getSheetAt(0);
  340. assertEquals("SUM(C2:C4)", getCellFormula(sheet, "C5"));
  341. assertEquals("SUM(D2:D4)", getCellFormula(sheet, "D5"));
  342. assertEquals("SUM(E2:E4)", getCellFormula(sheet, "E5"));
  343. assertEquals("SUM(C3:C5)", getCellFormula(sheet, "C6"));
  344. assertEquals("SUM(D3:D5)", getCellFormula(sheet, "D6"));
  345. assertEquals("SUM(E3:E5)", getCellFormula(sheet, "E6"));
  346. sheet.shiftRows(sheet.getFirstRowNum(), 4, -1);
  347. assertEquals("SUM(C1:C3)", getCellFormula(sheet, "C4"));
  348. assertEquals("SUM(D1:D3)", getCellFormula(sheet, "D4"));
  349. assertEquals("SUM(E1:E3)", getCellFormula(sheet, "E4"));
  350. assertEquals("SUM(C2:C4)", getCellFormula(sheet, "C6"));
  351. assertEquals("SUM(D2:D4)", getCellFormula(sheet, "D6"));
  352. assertEquals("SUM(E2:E4)", getCellFormula(sheet, "E6"));
  353. }
  354. }
  355. // bug 60260: shift rows or rename a sheet containing a named range
  356. // that refers to formula with a unicode (non-ASCII) sheet name formula
  357. @Test
  358. void shiftRowsWithUnicodeNamedRange() throws IOException {
  359. try (XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("unicodeSheetName.xlsx")) {
  360. XSSFSheet sheet = wb.getSheetAt(0);
  361. sheet.shiftRows(1, 2, 3);
  362. Integer[] exp = { 1, null, null, 4, 2, 3, 7, 8, 9 };
  363. IntStream.rangeClosed(0, 8).forEach(i -> {
  364. Row row = sheet.getRow(i);
  365. if (exp[i] == null) {
  366. assertNull(row);
  367. } else {
  368. assertEquals(exp[i], (int)row.getCell(0).getNumericCellValue());
  369. }
  370. });
  371. }
  372. }
  373. @Test
  374. void test60384() throws IOException {
  375. XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("60384.xlsx");
  376. XSSFSheet sheet = wb.getSheetAt(0);
  377. assertEquals(2, sheet.getMergedRegions().size());
  378. assertEquals(7, sheet.getMergedRegion(0).getFirstRow());
  379. assertEquals(7, sheet.getMergedRegion(0).getLastRow());
  380. assertEquals(8, sheet.getMergedRegion(1).getFirstRow());
  381. assertEquals(8, sheet.getMergedRegion(1).getLastRow());
  382. sheet.shiftRows(3, 8, 1);
  383. // after shifting, the two named regions should still be there as they
  384. // are fully inside the shifted area
  385. assertEquals(2, sheet.getMergedRegions().size());
  386. assertEquals(8, sheet.getMergedRegion(0).getFirstRow());
  387. assertEquals(8, sheet.getMergedRegion(0).getLastRow());
  388. assertEquals(9, sheet.getMergedRegion(1).getFirstRow());
  389. assertEquals(9, sheet.getMergedRegion(1).getLastRow());
  390. /*OutputStream out = new FileOutputStream("/tmp/60384.xlsx");
  391. try {
  392. wb.write(out);
  393. } finally {
  394. out.close();
  395. }*/
  396. wb.close();
  397. }
  398. @Test
  399. void test60709() throws IOException {
  400. XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("60709.xlsx");
  401. XSSFSheet sheet = wb.getSheetAt(0);
  402. assertEquals(1, sheet.getMergedRegions().size());
  403. assertEquals(2, sheet.getMergedRegion(0).getFirstRow());
  404. assertEquals(2, sheet.getMergedRegion(0).getLastRow());
  405. sheet.shiftRows(1, sheet.getLastRowNum()+1, -1, true, false);
  406. // after shifting, the two named regions should still be there as they
  407. // are fully inside the shifted area
  408. assertEquals(1, sheet.getMergedRegions().size());
  409. assertEquals(1, sheet.getMergedRegion(0).getFirstRow());
  410. assertEquals(1, sheet.getMergedRegion(0).getLastRow());
  411. /*OutputStream out = new FileOutputStream("/tmp/60709.xlsx");
  412. try {
  413. wb.write(out);
  414. } finally {
  415. out.close();
  416. }*/
  417. wb.close();
  418. }
  419. }