Skip to content

Instantly share code, notes, and snippets.

@guozheng
Created November 29, 2011 06:07
Show Gist options
  • Save guozheng/1403646 to your computer and use it in GitHub Desktop.
Save guozheng/1403646 to your computer and use it in GitHub Desktop.
color syntax sample for Tarun Bhadauria
/**
* 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