Finding number of cells in a Column in Excel

smith willy

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 ?

ystan-

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();

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

VBA Excel Finding and Combining Rows Based on Matching Column Cells

From Dev

Custom Function to Count Number of Used Cells in a Column in Excel 2010

From Dev

how to count of the number of filled cells in a column in an excel sheet

From Dev

how to count of the number of filled cells in a column in an excel sheet

From Dev

Reduce number of cells in Excel

From Dev

Reduce number of cells in Excel

From Dev

Finding all cells that have been filled with any color and highlighting corresponding column headers in excel vba

From Dev

Finding number of all nested cells in a complex cell

From Dev

finding the largest binary number from a range of cells

From Dev

Excel - Finding adjacent cells that equal a certain value

From Dev

Finding the largest number in a column in array

From Dev

Excel Count number of times in range that cells in column A are less than corresponding cell in column B

From Dev

Finding cells with at least the same text present in other cells (Excel)

From Dev

An Excel formula for number of merged cells?

From Dev

An Excel formula for number of merged cells?

From Dev

Excel - Sort cells by a number of matches

From Dev

Printing to Excel Cells by Column in VBA

From Dev

Using excel, how can I count the number of cells in a column containing the text "true" or "false"?

From Dev

how to compare text values between cells in same column and give specific ID(number) in excel vba

From Dev

Excel: count the number of cells in a column until their sum is greater than a set value

From Dev

Select column by number in Excel

From Dev

Finding line and column number in a long java string

From Dev

Finding a position with same number in row and column

From Dev

Finding relative row and column number of a range OR Cell

From Dev

Finding maximum value in a column and return row number

From Dev

Finding relative row and column number of a range OR Cell

From Dev

Finding Column number in CSV using python

From Dev

Finding Number of Occurrences Across Multiple Columns Excel

From Dev

MS Excel -Finding merged cells & combining info in them at corresponding row

Related Related

  1. 1

    VBA Excel Finding and Combining Rows Based on Matching Column Cells

  2. 2

    Custom Function to Count Number of Used Cells in a Column in Excel 2010

  3. 3

    how to count of the number of filled cells in a column in an excel sheet

  4. 4

    how to count of the number of filled cells in a column in an excel sheet

  5. 5

    Reduce number of cells in Excel

  6. 6

    Reduce number of cells in Excel

  7. 7

    Finding all cells that have been filled with any color and highlighting corresponding column headers in excel vba

  8. 8

    Finding number of all nested cells in a complex cell

  9. 9

    finding the largest binary number from a range of cells

  10. 10

    Excel - Finding adjacent cells that equal a certain value

  11. 11

    Finding the largest number in a column in array

  12. 12

    Excel Count number of times in range that cells in column A are less than corresponding cell in column B

  13. 13

    Finding cells with at least the same text present in other cells (Excel)

  14. 14

    An Excel formula for number of merged cells?

  15. 15

    An Excel formula for number of merged cells?

  16. 16

    Excel - Sort cells by a number of matches

  17. 17

    Printing to Excel Cells by Column in VBA

  18. 18

    Using excel, how can I count the number of cells in a column containing the text "true" or "false"?

  19. 19

    how to compare text values between cells in same column and give specific ID(number) in excel vba

  20. 20

    Excel: count the number of cells in a column until their sum is greater than a set value

  21. 21

    Select column by number in Excel

  22. 22

    Finding line and column number in a long java string

  23. 23

    Finding a position with same number in row and column

  24. 24

    Finding relative row and column number of a range OR Cell

  25. 25

    Finding maximum value in a column and return row number

  26. 26

    Finding relative row and column number of a range OR Cell

  27. 27

    Finding Column number in CSV using python

  28. 28

    Finding Number of Occurrences Across Multiple Columns Excel

  29. 29

    MS Excel -Finding merged cells & combining info in them at corresponding row

HotTag

Archive