2020
2121public class ExcelHelpers {
2222
23- private static FileInputStream fis ;
24- private static FileOutputStream fileOut ;
25- private static Workbook wb ;
26- private static Sheet sh ;
27- private static Cell cell ;
28- private static Row row ;
29- private static CellStyle cellstyle ;
30- private static Color mycolor ;
31- private static String excelFilePath ;
32- private static Map <String , Integer > columns = new HashMap <>();
33-
34- public static int rowNumber ; //Row Number
35- public static int columnNumber ; //Column Number
23+ private FileInputStream fis ;
24+ private FileOutputStream fileOut ;
25+ private Workbook wb ;
26+ private Sheet sh ;
27+ private Cell cell ;
28+ private Row row ;
29+ private CellStyle cellstyle ;
30+ private Color mycolor ;
31+ private String excelFilePath ;
32+ private Map <String , Integer > columns = new HashMap <>();
33+
34+ public int rowNumber ; //Row Number
35+ public int columnNumber ; //Column Number
3636
3737 // Set Excel file
38- public static void setExcelFile (String excelPath , String sheetName ) {
38+ public void setExcelFile (String excelPath , String sheetName ) {
3939 try {
4040 File f = new File (excelPath );
4141
@@ -85,12 +85,12 @@ public static void setExcelFile(String excelPath, String sheetName) {
8585 }
8686
8787 //Phương thức này nhận số hàng làm tham số và trả về dữ liệu của hàng đó.
88- public static Row getRowData (int rowNum ) {
88+ public Row getRowData (int rowNum ) {
8989 row = sh .getRow (rowNum );
9090 return row ;
9191 }
9292
93- public static Object [][] getDataArray (String excelPath , String sheetName , int startCol , int totalCols ) {
93+ public Object [][] getDataArray (String excelPath , String sheetName , int startCol , int totalCols ) {
9494
9595 Object [][] data = null ;
9696 try {
@@ -147,7 +147,7 @@ public static Object[][] getDataArray(String excelPath, String sheetName, int st
147147 return data ;
148148 }
149149
150- public static Object [][] getTableArray (String filePath , String sheetName , int iTestCaseRow ) throws Exception {
150+ public Object [][] getTableArray (String filePath , String sheetName , int iTestCaseRow ) throws Exception {
151151
152152 String [][] tabArray = null ;
153153
@@ -181,7 +181,7 @@ public static Object[][] getTableArray(String filePath, String sheetName, int iT
181181 return (tabArray );
182182 }
183183
184- public static Object [][] getDataHashTable (String excelPath , String sheetName , int startRow , int endRow ) {
184+ public Object [][] getDataHashTable (String excelPath , String sheetName , int startRow , int endRow ) {
185185
186186 Object [][] data = null ;
187187 try {
@@ -223,7 +223,7 @@ public static Object[][] getDataHashTable(String excelPath, String sheetName, in
223223 return data ;
224224 }
225225
226- public static String getTestCaseName (String sTestCase ) throws Exception {
226+ public String getTestCaseName (String sTestCase ) throws Exception {
227227 String value = sTestCase ;
228228 try {
229229 int posi = value .indexOf ("@" );
@@ -238,7 +238,7 @@ public static String getTestCaseName(String sTestCase) throws Exception {
238238 }
239239 }
240240
241- public static int getRowContains (String sTestCaseName , int colNum ) throws Exception {
241+ public int getRowContains (String sTestCaseName , int colNum ) throws Exception {
242242 int i ;
243243 try {
244244 int rowCount = getRowUsed ();
@@ -255,7 +255,7 @@ public static int getRowContains(String sTestCaseName, int colNum) throws Except
255255
256256 }
257257
258- public static int getRowUsed () throws Exception {
258+ public int getRowUsed () throws Exception {
259259 try {
260260 int RowCount = sh .getLastRowNum ();
261261 return RowCount ;
@@ -266,7 +266,7 @@ public static int getRowUsed() throws Exception {
266266 }
267267
268268 // Get cell data
269- public static String getCellData (int rownum , int colnum ) {
269+ public String getCellData (int rownum , int colnum ) {
270270 try {
271271 cell = sh .getRow (rownum ).getCell (colnum );
272272 String CellData = null ;
@@ -294,27 +294,27 @@ public static String getCellData(int rownum, int colnum) {
294294 }
295295 }
296296
297- public static String getCellData (int rowNum , String columnName ) {
297+ public String getCellData (int rowNum , String columnName ) {
298298 return getCellData (rowNum , columns .get (columnName ));
299299 }
300300
301- public static int getRows () {
301+ public int getRows () {
302302 return sh .getPhysicalNumberOfRows ();
303303 }
304304
305- public static int getRowCount () {
305+ public int getRowCount () {
306306 int rowCount = sh .getLastRowNum () + 1 ;
307307 return rowCount ;
308308 }
309309
310- public static int getColumnCount () {
310+ public int getColumnCount () {
311311 row = sh .getRow (0 );
312312 int colCount = row .getLastCellNum ();
313313 return colCount ;
314314 }
315315
316316 // Write data to excel sheet
317- public static void setCellData (String text , int rowNumber , int colNumber ) {
317+ public void setCellData (String text , int rowNumber , int colNumber ) {
318318 try {
319319 row = sh .getRow (rowNumber );
320320 if (row == null ) {
@@ -348,7 +348,7 @@ public static void setCellData(String text, int rowNumber, int colNumber) {
348348 }
349349 }
350350
351- public static void setCellData (String text , int rowNum , String columnName ) {
351+ public void setCellData (String text , int rowNum , String columnName ) {
352352 try {
353353 row = sh .getRow (rowNum );
354354 if (row == null ) {
0 commit comments