I want to find the number of contents in a column from Excel File.
Example
Location Device Second
1 A 10
2 B 20
3 30
Now, I want that it should display, Location: 3 Device: 2 Second: 3
I am using jxl.
Workbook existingWorkbook = Workbook.getWorkbook(new File(filename1));
WritableWorkbook workbookCopy = Workbook.createWorkbook(new File(filename1), existingWorkbook);
WritableSheet sheetToEdit = workbookCopy.getSheet(0);
int n= sheetToEdit.getcolumns();
System.out.println(n);
workbookCopy.write();
workbookCopy.close();
Here, I am getting, only the number of columns,
Can u tell me, how I can do that ?
i don't think there's a direct way to do that beyond manual counting and determining empty cells:
Workbook existingWorkbook = Workbook.getWorkbook(new File(filename1));
WritableWorkbook workbookCopy = Workbook.createWorkbook(new File(filename1), existingWorkbook);
WritableSheet sheetToEdit = workbookCopy.getSheet(0);
for (int i=0; i<sheetToEdit.getcolumns(); i++) {
int columnCount = 0;
for (Cell cell : sheetToEdit.getColumn(i))
if (!cell.getContents().equals(""))
columnCount++;
System.out.println(columnCount);
}
workbookCopy.write();
workbookCopy.close();