From 7de715c611528c7afa5d57395cc0e631d58bc153 Mon Sep 17 00:00:00 2001 From: Gang Date: Wed, 1 Jan 2020 21:34:48 -0700 Subject: [PATCH 1/3] BAEL-3656 Read Numeric Strings in Excel Cells as a String with Apache POI --- apache-poi/pom.xml | 2 +- .../poi/excel/ExcelCellFormatter.java | 20 +++ .../ExcelCellFormatterIntegrationTest.java | 128 ++++++++++++++++++ 3 files changed, 149 insertions(+), 1 deletion(-) create mode 100644 apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java create mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java diff --git a/apache-poi/pom.xml b/apache-poi/pom.xml index a114946c47..333339ed33 100644 --- a/apache-poi/pom.xml +++ b/apache-poi/pom.xml @@ -32,7 +32,7 @@ - 3.15 + 4.1.1 1.0.6 diff --git a/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java new file mode 100644 index 0000000000..4a8854620c --- /dev/null +++ b/apache-poi/src/main/java/com/baeldung/poi/excel/ExcelCellFormatter.java @@ -0,0 +1,20 @@ +package com.baeldung.poi.excel; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Workbook; + +public class ExcelCellFormatter { + + public String getCellStringValue(Cell cell) { + DataFormatter formatter = new DataFormatter(); + return formatter.formatCellValue(cell); + } + + public String getCellStringValueWithFormula(Cell cell, Workbook workbook) { + DataFormatter formatter = new DataFormatter(); + FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator(); + return formatter.formatCellValue(cell, evaluator); + } +} diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java new file mode 100644 index 0000000000..889ee1b527 --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java @@ -0,0 +1,128 @@ +package com.baeldung.poi.excel; + +import static org.junit.Assert.assertEquals; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; + +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.DataFormat; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ExcelCellFormatterIntegrationTest { + private static int STRING_CELL_INDEX = 0; + private static int BOOLEAN_CELL_INDEX = 1; + private static int RAW_NUMERIC_CELL_INDEX = 2; + private static int FORMATTED_NUMERIC_CELL_INDEX = 3; + private static int FORMULA_CELL_INDEX = 4; + + private String fileLocation; + + @Before + public void generateExcelFile() throws IOException { + + Workbook workbook = new XSSFWorkbook(); + + Sheet sheet = workbook.createSheet("Test"); + Row row = sheet.createRow(0); + Cell cell = row.createCell(STRING_CELL_INDEX); + cell.setCellValue("String Test"); // STRING cell + + cell = row.createCell(BOOLEAN_CELL_INDEX); + cell.setCellValue(true); // BOOLEAN cell + + cell = row.createCell(RAW_NUMERIC_CELL_INDEX); + cell.setCellValue(1234.5678); // NUMERIC cell + + cell = row.createCell(FORMATTED_NUMERIC_CELL_INDEX); + cell.setCellValue(1234.5678); + CellStyle curStyle = workbook.createCellStyle(); + DataFormat df = workbook.createDataFormat(); + curStyle.setDataFormat(df.getFormat("$#,##0.00")); + cell.setCellStyle(curStyle); // NUMERIC cell with format rule + + cell = row.createCell(FORMULA_CELL_INDEX); + cell.setCellFormula("SUM(C1:D1)"); // FORMULA cell + + File tempFile = File.createTempFile("ExcelCellFormatterIntegrationTest", ".xlsx"); + + fileLocation = tempFile.getAbsolutePath(); + + FileOutputStream outputStream = new FileOutputStream(fileLocation); + workbook.write(outputStream); + workbook.close(); + outputStream.close(); + } + + @Test + public void gvieStringCell_whenGetCellStringValue_thenReturnStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("String Test", formatter.getCellStringValue(row.getCell(STRING_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieBooleanCell_whenGetCellStringValue_thenReturnBooleanStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("TRUE", formatter.getCellStringValue(row.getCell(BOOLEAN_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieNumericCell_whenGetCellStringValue_thenReturnNumericStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("1234.5678", formatter.getCellStringValue(row.getCell(RAW_NUMERIC_CELL_INDEX))); + assertEquals("$1,234.57", formatter.getCellStringValue(row.getCell(FORMATTED_NUMERIC_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieFormualCell_whenGetCellStringValue_thenReturnOriginalFormulaString() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("SUM(C1:D1)", formatter.getCellStringValue(row.getCell(FORMULA_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieFormualCell_whenGetCellStringValueForFormula_thenReturnOriginalFormulatring() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("2469.1356", formatter.getCellStringValueWithFormula(row.getCell(FORMULA_CELL_INDEX), workbook)); + workbook.close(); + } + + @After + public void cleanup() { + File testFile = new File(fileLocation); + if (testFile.exists()) { + testFile.deleteOnExit(); + } + } +} \ No newline at end of file From f484bcb498e131b232a4650a4d0bf70b6a7740df Mon Sep 17 00:00:00 2001 From: Gang Date: Sun, 5 Jan 2020 00:19:49 -0700 Subject: [PATCH 2/3] BAEL-3656 Change the integration test into unit test. --- .../resources/ExcelCellFormatterTest.xlsx | Bin 0 -> 3375 bytes .../ExcelCellFormatterIntegrationTest.java | 128 ------------------ .../poi/excel/ExcelCellFormatterUnitTest.java | 87 ++++++++++++ 3 files changed, 87 insertions(+), 128 deletions(-) create mode 100644 apache-poi/src/main/resources/ExcelCellFormatterTest.xlsx delete mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java create mode 100644 apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java diff --git a/apache-poi/src/main/resources/ExcelCellFormatterTest.xlsx b/apache-poi/src/main/resources/ExcelCellFormatterTest.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..54e8734d58f7e14ba90c1bd65417142c460db369 GIT binary patch literal 3375 zcmaJ@2{@E%8y-f+P?4l59h3=8#W*8tc4`>QjHHm=ScWmiR*WUokbO_tvUEsMvNo~| z*&-o(nIj^Sts_gwKcoLY=J-!N-}TKmb6wx_&ig#?{oMDBMgiIQ02~|~fJ(q|G=M4g z)4!W(5L`X6uAY`gK5keKbBSwsm$D0OuJv%9^`w@5n9L&j;(;Iyp=SOEi@+Nc$Ja9FKfyu`i1R)Z=a;jzn{{ z-T6dwlxTHaxm4O&elBP)Zan{n2B!DkbV^vt(;)wjXS%Bw6?pkHGxmoE=dK>7g%;<> zj+|;xf8Mf?Zx#v8Z4wk#Y%9JEUL@%+rUZlzTwVxqYdqrPY@nOP28ngnzivF6yO8&; zR^2p!{N#B?AQ7?@ILIv=Zhc6|J?uTnpq2%V0&(~zz9cHL002kW008t)d(TDhy`?+W z#Y0kp@mUy8#WlcplPw!3X>v1Gk(i3xzfa;LXIZ4pv~_LT28NQWH`*o4P@Dpv#i9P2 zpl)xKQ0;1rL`F`K*PGyM$HCPBfosZ2k7iX5P$%6+k?hAB0xJBo!S`Jgsd?G3WBkAn zB&DA+5X72H-rqPhB?n40ov;uq6=ka!^h8B zFg3g|Dn_#wJYMuy@?IB9pq5EXO$wm;^V3ytqKgosUr%?c7VF3#9{mp1%l2~g!4(9> z1pYK_ilEaUlMMtb@U3TCa7>j54fwM%dXpFFTRldvT$}Y*z2Tw1VMnkUC_@a2h|EzF52g z*XtOSAGm$qW_PmilrRUoOP;(yqBct)ftHQUu zzmwi5oXo$fP5XE@?fLjpKKa9M>2py<$P7&UJ^ph`l)@I<5|k`-A;`HElv8|cC>C$d z*>;0id9^8(uRmc)|FXHay;WV%zZN|vXFrCU7(FL{c6eC1 zy)CagqeddOXI%T$4GlrGD5kDHG%CtZEVQ@Rt3}6Z3?A|GbHO^d??&k@Rr1cE{RX@N{=_ zb?{*HQ7KAoZ!nxkYgv?*b*Fka1>ThS6u!VZ%5oTz1x{CYfD8UfA+CPkTzy@hDVHjX z1>X{oGd=?uRo)ZS%$_m4;TF_4bJbW=FH@%Pch(Z(Wm(F`v$QAD@COo?G^fPEEec9` zZcik+FPg$*#8ILuEtnBHsCL6%^iMQx`+u zZow~6vFE=9dHT3uw<<}GS0XeB^N^QyHn_v8sS9YWq?z4GSG=a;jXvqL51t!GT^FgU zt+7gbkzU|EIy+7a4apgZF}#Pk+*}4*@J_I1E9i=RSoC79`I~j&sXM@ec}ZN@DE^^iMUcoko#zpEvw01B5eL@oR@-ypBTlsX@J;C7 zR%lHs$3UkNeTdW-H!Ef0#^}jew2+Hl$WC4%G2n4yQ?>ebuUaDnPQ~(6x^c7*7?fFx zwdR~&6MFz-D^-S^n)_Dii$}g&v}ogj>nj%KhqXl5f?3O1j_xIT3e9jY4P;A)T;k6Z zYMi#L@9g9i)zvu`sE7J|KxXqGf7DFUW<&aBYgE3JjjzB5u!~Y4m6xPgS2pv^)_tw9 zSC%obEQ(|4R&<PO9v#4mQeglJmkn163S8*VoU~zrP1BQen ztjmSfPLG*4 zyl1cfo#pnc=>sfEPLpAXFeAl>M`vb$VU5EFO-`?#f%ePJY<1;e?Z)Xrdd*jUIe~|N zbmfO^G56+&gvIGO(16c?e9 z^Ca$4T0lpFPxCR6gpeX9s_?F8kv)4YmJMW=tu&RiRHU+iHUqAGujPCSRiIHOx>~Vv z$bwa>DH!Y^xyK=wGWD$8V!C9v%$nOgaOmP&+Ms*K_2X|oXNNqE_${Sc5?BD#uCem# zGHlCzFhWtVUyn&%3)sEV@*aP#o6EcEdPwz=5`~Dau^au5SN`~ZzjmWH&`lnx-gCj{ zx8X8W09ziUs&Z+9i-8z2P%*BDUOD2Ih=FV)#={Yd_4J?<75yQ##q{xJ1|h0EH~-XI z=T7zShL|`O-eq?zz}pJlg*f|LT2gUs-tXP*-e;?+Y zv-r_-!cq31nbH+R&1Cm;fn-(K)#Cw^6MMo>ogebld?0c}su~KK@%kR}*W%pR=f|3V&LnumF(cPX@5m+_x@p0~Z-xA8gEPF)_vI^cI zAAN72d3a3;cZaHT_Ypc->oDe$C*q^i3zLE~!A`xgC24{mp*qOo>CyH@&?j8aSL^cX zxhWxzz%9XDBzV>!=_r-mIt><9KESrOWp-W+Z~M>q7pIFx{c{0kd%`ei+u=w5OD4Ov zGm+T_Fx<;_q|o=d)64A4X4XH3RoD(EAXE1LjKj`!X0>66y!oQz-p0XhyWcmMzZ literal 0 HcmV?d00001 diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java deleted file mode 100644 index 889ee1b527..0000000000 --- a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterIntegrationTest.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.baeldung.poi.excel; - -import static org.junit.Assert.assertEquals; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; - -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.DataFormat; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ExcelCellFormatterIntegrationTest { - private static int STRING_CELL_INDEX = 0; - private static int BOOLEAN_CELL_INDEX = 1; - private static int RAW_NUMERIC_CELL_INDEX = 2; - private static int FORMATTED_NUMERIC_CELL_INDEX = 3; - private static int FORMULA_CELL_INDEX = 4; - - private String fileLocation; - - @Before - public void generateExcelFile() throws IOException { - - Workbook workbook = new XSSFWorkbook(); - - Sheet sheet = workbook.createSheet("Test"); - Row row = sheet.createRow(0); - Cell cell = row.createCell(STRING_CELL_INDEX); - cell.setCellValue("String Test"); // STRING cell - - cell = row.createCell(BOOLEAN_CELL_INDEX); - cell.setCellValue(true); // BOOLEAN cell - - cell = row.createCell(RAW_NUMERIC_CELL_INDEX); - cell.setCellValue(1234.5678); // NUMERIC cell - - cell = row.createCell(FORMATTED_NUMERIC_CELL_INDEX); - cell.setCellValue(1234.5678); - CellStyle curStyle = workbook.createCellStyle(); - DataFormat df = workbook.createDataFormat(); - curStyle.setDataFormat(df.getFormat("$#,##0.00")); - cell.setCellStyle(curStyle); // NUMERIC cell with format rule - - cell = row.createCell(FORMULA_CELL_INDEX); - cell.setCellFormula("SUM(C1:D1)"); // FORMULA cell - - File tempFile = File.createTempFile("ExcelCellFormatterIntegrationTest", ".xlsx"); - - fileLocation = tempFile.getAbsolutePath(); - - FileOutputStream outputStream = new FileOutputStream(fileLocation); - workbook.write(outputStream); - workbook.close(); - outputStream.close(); - } - - @Test - public void gvieStringCell_whenGetCellStringValue_thenReturnStringValue() throws IOException { - Workbook workbook = new XSSFWorkbook(fileLocation); - Sheet sheet = workbook.getSheetAt(0); - Row row = sheet.getRow(0); - - ExcelCellFormatter formatter = new ExcelCellFormatter(); - assertEquals("String Test", formatter.getCellStringValue(row.getCell(STRING_CELL_INDEX))); - workbook.close(); - } - - @Test - public void gvieBooleanCell_whenGetCellStringValue_thenReturnBooleanStringValue() throws IOException { - Workbook workbook = new XSSFWorkbook(fileLocation); - Sheet sheet = workbook.getSheetAt(0); - Row row = sheet.getRow(0); - - ExcelCellFormatter formatter = new ExcelCellFormatter(); - assertEquals("TRUE", formatter.getCellStringValue(row.getCell(BOOLEAN_CELL_INDEX))); - workbook.close(); - } - - @Test - public void gvieNumericCell_whenGetCellStringValue_thenReturnNumericStringValue() throws IOException { - Workbook workbook = new XSSFWorkbook(fileLocation); - Sheet sheet = workbook.getSheetAt(0); - Row row = sheet.getRow(0); - - ExcelCellFormatter formatter = new ExcelCellFormatter(); - assertEquals("1234.5678", formatter.getCellStringValue(row.getCell(RAW_NUMERIC_CELL_INDEX))); - assertEquals("$1,234.57", formatter.getCellStringValue(row.getCell(FORMATTED_NUMERIC_CELL_INDEX))); - workbook.close(); - } - - @Test - public void gvieFormualCell_whenGetCellStringValue_thenReturnOriginalFormulaString() throws IOException { - Workbook workbook = new XSSFWorkbook(fileLocation); - Sheet sheet = workbook.getSheetAt(0); - Row row = sheet.getRow(0); - - ExcelCellFormatter formatter = new ExcelCellFormatter(); - assertEquals("SUM(C1:D1)", formatter.getCellStringValue(row.getCell(FORMULA_CELL_INDEX))); - workbook.close(); - } - - @Test - public void gvieFormualCell_whenGetCellStringValueForFormula_thenReturnOriginalFormulatring() throws IOException { - Workbook workbook = new XSSFWorkbook(fileLocation); - Sheet sheet = workbook.getSheetAt(0); - Row row = sheet.getRow(0); - - ExcelCellFormatter formatter = new ExcelCellFormatter(); - assertEquals("2469.1356", formatter.getCellStringValueWithFormula(row.getCell(FORMULA_CELL_INDEX), workbook)); - workbook.close(); - } - - @After - public void cleanup() { - File testFile = new File(fileLocation); - if (testFile.exists()) { - testFile.deleteOnExit(); - } - } -} \ No newline at end of file diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java new file mode 100644 index 0000000000..adedf951d6 --- /dev/null +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java @@ -0,0 +1,87 @@ +package com.baeldung.poi.excel; + +import static org.junit.Assert.assertEquals; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Paths; + +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.junit.Before; +import org.junit.Test; + +public class ExcelCellFormatterUnitTest { + private static final String FILE_NAME = "ExcelCellFormatterTest.xlsx"; + private static final int STRING_CELL_INDEX = 0; + private static final int BOOLEAN_CELL_INDEX = 1; + private static final int RAW_NUMERIC_CELL_INDEX = 2; + private static final int FORMATTED_NUMERIC_CELL_INDEX = 3; + private static final int FORMULA_CELL_INDEX = 4; + + private String fileLocation; + + @Before + public void setup() throws IOException, URISyntaxException { + fileLocation = Paths.get(ClassLoader.getSystemResource(FILE_NAME).toURI()).toString(); + } + + @Test + public void gvieStringCell_whenGetCellStringValue_thenReturnStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("String Test", formatter.getCellStringValue(row.getCell(STRING_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieBooleanCell_whenGetCellStringValue_thenReturnBooleanStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("TRUE", formatter.getCellStringValue(row.getCell(BOOLEAN_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieNumericCell_whenGetCellStringValue_thenReturnNumericStringValue() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("1.234", formatter.getCellStringValue(row.getCell(RAW_NUMERIC_CELL_INDEX))); + assertEquals("1.23", formatter.getCellStringValue(row.getCell(FORMATTED_NUMERIC_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieFormualCell_whenGetCellStringValue_thenReturnOriginalFormulaString() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("SUM(1+2)", formatter.getCellStringValue(row.getCell(FORMULA_CELL_INDEX))); + workbook.close(); + } + + @Test + public void gvieFormualCell_whenGetCellStringValueForFormula_thenReturnOriginalFormulatring() throws IOException { + Workbook workbook = new XSSFWorkbook(fileLocation); + Sheet sheet = workbook.getSheetAt(0); + Row row = sheet.getRow(0); + + ExcelCellFormatter formatter = new ExcelCellFormatter(); + assertEquals("3", formatter.getCellStringValueWithFormula(row.getCell(FORMULA_CELL_INDEX), workbook)); + workbook.close(); + } + +} \ No newline at end of file From be324f6d097fa3b84473c16c4d45449a65cd6efa Mon Sep 17 00:00:00 2001 From: Gang Date: Wed, 8 Jan 2020 20:07:32 -0700 Subject: [PATCH 3/3] BAEL-3656 Fix typos in the unit test names. --- .../baeldung/poi/excel/ExcelCellFormatterUnitTest.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java index adedf951d6..d9f96ee93c 100644 --- a/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java +++ b/apache-poi/src/test/java/com/baeldung/poi/excel/ExcelCellFormatterUnitTest.java @@ -29,7 +29,7 @@ public class ExcelCellFormatterUnitTest { } @Test - public void gvieStringCell_whenGetCellStringValue_thenReturnStringValue() throws IOException { + public void givenStringCell_whenGetCellStringValue_thenReturnStringValue() throws IOException { Workbook workbook = new XSSFWorkbook(fileLocation); Sheet sheet = workbook.getSheetAt(0); Row row = sheet.getRow(0); @@ -40,7 +40,7 @@ public class ExcelCellFormatterUnitTest { } @Test - public void gvieBooleanCell_whenGetCellStringValue_thenReturnBooleanStringValue() throws IOException { + public void givenBooleanCell_whenGetCellStringValue_thenReturnBooleanStringValue() throws IOException { Workbook workbook = new XSSFWorkbook(fileLocation); Sheet sheet = workbook.getSheetAt(0); Row row = sheet.getRow(0); @@ -51,7 +51,7 @@ public class ExcelCellFormatterUnitTest { } @Test - public void gvieNumericCell_whenGetCellStringValue_thenReturnNumericStringValue() throws IOException { + public void givenNumericCell_whenGetCellStringValue_thenReturnNumericStringValue() throws IOException { Workbook workbook = new XSSFWorkbook(fileLocation); Sheet sheet = workbook.getSheetAt(0); Row row = sheet.getRow(0); @@ -63,7 +63,7 @@ public class ExcelCellFormatterUnitTest { } @Test - public void gvieFormualCell_whenGetCellStringValue_thenReturnOriginalFormulaString() throws IOException { + public void givenFormualCell_whenGetCellStringValue_thenReturnOriginalFormulaString() throws IOException { Workbook workbook = new XSSFWorkbook(fileLocation); Sheet sheet = workbook.getSheetAt(0); Row row = sheet.getRow(0); @@ -74,7 +74,7 @@ public class ExcelCellFormatterUnitTest { } @Test - public void gvieFormualCell_whenGetCellStringValueForFormula_thenReturnOriginalFormulatring() throws IOException { + public void givenFormualCell_whenGetCellStringValueForFormula_thenReturnOriginalFormulatring() throws IOException { Workbook workbook = new XSSFWorkbook(fileLocation); Sheet sheet = workbook.getSheetAt(0); Row row = sheet.getRow(0);