Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Identify the blank cells in a column while reading open office spreadsheet and display them without inserting into database

  1. #1
    Junior Member
    Join Date
    Jul 2017
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Identify the blank cells in a column while reading open office spreadsheet and display them without inserting into database

    Below is my code which is used to read open office spread sheet data where i have 16 columns in it the problem is out of 16 columns i have 14 th column where the data cannot be empty in that 14 th column if any cell is empty i should show an error message by showing the row numbers of that column that these rows are empty please fill and if all the cells are filled in that column the data should get inserted into database how can i do this can any one help me outas i am new to this



    public void readODS(File file)
    {
    Sheet sheet;
    try
    {
    //Getting the 0th sheet for manipulation| pass sheet name as string
    sheet = SpreadSheet.createFromFile(file).getSheet(0);

    //Get row count and column count
    int nColCount = sheet.getColumnCount();
    int nRowCount = sheet.getRowCount();

    System.out.println("Rows :"+nRowCount);
    System.out.println("Cols :"+nColCount);
    //Iterating through each row of the selected sheet
    MutableCell cell = null;
    for(int nRowIndex = 0; nRowIndex < nRowCount; nRowIndex++)
    {
    //Iterating through each column
    int nColIndex = 0;
    for( ;nColIndex < nColCount; nColIndex++)
    {
    cell = sheet.getCellAt(nColIndex, nRowIndex);
    System.out.print(cell.getValue()+ " ");
    }
    System.out.println();
    }

    }
    catch (IOException e)
    {
    e.printStackTrace();
    }
    }
    public static void main(String[] args) {
    //Creating File object of .ods file
    File file = new File("D:\\Users\\test.ods");
    OdsReader objODSReader = new OdsReader();
    objODSReader.readODS(file);
    }

    My above code prints the spreadsheet data on the console but what i need is i need to insert the data in database if the data in 14th column is not empty if any cell is empty it should show row numbers which are empty in that column.can anyone help me out as i am learner and new to this

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Identify the blank cells in a column while reading open office spreadsheet and display them without inserting into database

    Also posted at: https://www.java-forums.org/new-java...tml#post419094

    Please read: http://www.javaprogrammingforums.com...s-posting.html
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Insert Text in Column Cells
    By theperfectpunk in forum JavaFX
    Replies: 1
    Last Post: February 23rd, 2014, 05:19 AM
  2. Reading until a Blank Line. File input.
    By iCurtisIT in forum Loops & Control Statements
    Replies: 5
    Last Post: November 25th, 2013, 02:13 PM
  3. Replies: 0
    Last Post: July 24th, 2013, 02:09 AM
  4. [SOLVED] Inserting into database through swing
    By learn_java in forum JDBC & Databases
    Replies: 1
    Last Post: November 6th, 2012, 02:03 PM
  5. Connect to open document format (.ods) spreadsheet
    By Ayla in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: May 27th, 2011, 04:50 PM

Tags for this Thread