Created
November 29, 2011 06:07
-
-
Save guozheng/1403646 to your computer and use it in GitHub Desktop.
color syntax sample for Tarun Bhadauria
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reads data from excel file | |
* | |
* @param path | |
* @param sheetNumber | |
* @param colNumber | |
* @param startRowNumber | |
* @return | |
* @throws Exception | |
*/ | |
public static ArrayList getColumnDataFromExcel(String path, | |
int sheetNumber, int colNumber, int startRowNumber) | |
throws Exception { | |
// Stores excel column content | |
ArrayList columnContent = new ArrayList(); | |
jxl.Workbook workbook = null; | |
jxl.Sheet sheet = null; | |
workbook = jxl.Workbook.getWorkbook(new File(path)); | |
sheet = workbook.getSheet(sheetNumber); | |
int rows = 0; | |
rows = sheet.getRows(); | |
// Retrieves column data | |
for (int i = startRowNumber; i < rows; i++) { // Retrieving values based | |
// on column number and | |
// starting row number. | |
Cell value = sheet.getCell(colNumber, i); | |
// Values are retrieved when cell contents are not null. | |
if (value.getContents() != null) { | |
columnContent.add(value.getContents()); | |
} | |
} | |
return columnContent; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment