hariprasad
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code
0 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners

//here my file nameis sample.xls and this file contain some blanks cells how to read and how to print this blank cell as blank in console

public ArrayList readCSV(File fileName) { ArrayList cellVectorHolder = new ArrayList(); try{

            FileInputStream myInput = new FileInputStream(fileName);
            POIFSFileSystem myFileSystem = new POIFSFileSystem(myInput);
            HSSFWorkbook myWorkBook = new HSSFWorkbook(myFileSystem);
            HSSFSheet mySheet = myWorkBook.getSheetAt(0);
           Iterator rowIter = mySheet.rowIterator(); 
           while(rowIter.hasNext())
           {

                  HSSFRow myRow = (HSSFRow) rowIter.next();
                  Iterator cellIter = myRow.cellIterator();
                  ArrayList cellStoreVector=new ArrayList();
                  String header_name = null;
                  while(cellIter.hasNext())
                  {

                          HSSFCell myCell = (HSSFCell) cellIter.next();
                          //if it is empty cell in  my excel file its not added to array ist 
                          cellStoreVector.add(myCell);

                  }
                  cellVectorHolder.add(cellStoreVector);
           }
    }
    catch (Exception e){e.printStackTrace(); }
    return cellVectorHolder;
}

public void saveToDatabase(ArrayList array)
{

    for (int i=0;i<array.size(); i++)
    {
        ArrayList cellStoreVector=(ArrayList)array.get(i);
        for (int j=0; j < cellStoreVector.size();j++)
        {
            HSSFCell myCell = (HSSFCell)cellStoreVector.get(j);
            String st = myCell.toString();
            System.out.println("values "+st);

        }
    }
}

sir, the above code is my sample code for reading excel file and print values into console here i have a problem when reading blank cells and this blank cells are not displayed in the console. so please give me solution for reading blank cell and print this blank in console. thank you.........

Advertisement
View Answers









Related Tutorials/Questions & Answers:
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code
sir, how to read empty cell in excel file using poi and how to add this empty cell to arraay list and the following is my code   //here my file...) cellIter.next(); //if it is empty cell in my excel file
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?
How to read every cell of an excel sheet using Apache POI and insert those data into a DB?   i have an excel sheet, whose data in each cell has... the rows of an excel sheet. Need the source code
Advertisements
Table Empty Cell in HTML
of table. The code is not able to display border around the empty cell in a table.... The code create a html page ,which shows you a table  with empty cell. <... Table Empty Cell in HTML     
Excel Cell Comment
Excel Cell Comment In this section, you will learn how to add a comment with a excel cell using Apache POI API. A comment is associated with a cell... box. So we can say that comment stored separately but attached with a cell
Excel Cell Drop Down List
Excel Cell Drop Down List In this section, you will learn how to validate data entered in a cell and provide a drop down list of possible values to the user... in a excel sheet's cell and also can provide drop list of possible value
How to read a rows which have a values in a excel file using apache poi - JSP-Servlet
How to read a rows which have a values in a excel file using apache poi  Dear sir, How to read excel file in that only a rows which are having some values using apache poi...please help me sir. Thanks and Regards
Read Excel(.xlsx) document using Apache POI
Read Excel(.xlsx) document using Apache POI In this section, you will learn how to read Excel file having .xlsx extension using Apache POI library. In the below example, we will read excel document having one sheet named as "new
insert checkbox in cell using POI api in java
insert checkbox in cell using POI api in java  I need to insert checkbox in excel cell using POI and java. Any one help me on this. Ashok S
sir, how to convert excel file to csv file using java? please send me sample code.
sir, how to convert excel file to csv file using java? please send me sample code.  please send me sample code for converting excel file into csv file uisng java
Read Simple Excel(.xls) document using Apache POI
Read Simple Excel(.xls) document using Apache POI In this section, you will learn how to read Excel file having .xls extension using Apache POI library... the data read from excel sheet. // List sheetData = new ArrayList
Identify Excel's cell data type
Identify Excel's cell data type In this section, you will learn how you can identify cell's data type and handle it appropriately using Apache POI... to identify each type of excel cell correctly to handle it appropriately
How to Read Excel file Using Java
How to Read Excel file In this section,you will learn how to read excel file... and every cell and stored the excel file values into the vector.This Vector data is then used to display file values on the console. Here is the code
non empty file
Java Delete non empty file  f.delete() works when the file is empty.if a file be non empty how to delete it???   Please visit the following link: http://www.roseindia.net/tutorial/java/core/files
Find String Values of Cell Using POI
Find String Values of Cell Using POI   ... Values of Cell of  an excel sheet using POI3.0 API Event. The class ... SSTRecord . The code of the program is given below: import 
How to create a JTable cell containing Image hyperlink?
How to create a JTable cell containing Image hyperlink?  I'm trying to find out how to create a JTable cell which contains Image, which should.... Can somebody explain me how to add hyperlink (mouse listener) for the each
How to set background of an excel sheet using POI - Java Magazine
How to set background of an excel sheet using POI  Hi, i am trying to format the excel using java. How to set the background color of an excel... using POI: For read more in details to visit.... http
how to read data from excel file through browse and insert into oracle database using jsp or oracle???
how to read data from excel file through browse and insert into oracle database using jsp or oracle???  sir.. i have number of excel sheets which...://www.roseindia.net/answers/viewqa/JSP-Servlet/28123-write-excel-file-into-the-oracle
Check if the directory is empty or not
Check if the directory is empty or not In this section, you will learn how... of this array is not zero, the directory is considered as non empty. Here is the code...."); } } } } Through the above code, you can check whether the specified directory is empty
Format Cell of Simple Excel Sheet(.xls)
Format Cell of Simple Excel  Sheet(.xls) In this section, you will how to format the cell of a simple excel sheet having extension .xls. In the below... out the workbook into an excel file. // FileOutputStream fos = null; try
Excel Created using POI and HSSF - Development process
Excel Created using POI and HSSF  Hi i ceated excel file using jakarta poi library i want to add Percentage formula to cell i am not able to do that can you please suggest me how do i add formula c3.setCellValue("Percentage
Java Read .doc file using POI library
Java Read .doc file using POI library In this section, you will learn how to read the word document file using POI library. The class HWPFDocument throw all... and displayed the data of word file on console. Here is the code of ReadDoc.java
How would you read in and add all this into a list?
How would you read in and add all this into a list?   FYI this is all stacked. 0 " " " " " " " " " " 1 "48" "111" "Dallam" "06" "County" 2 "48" "421" "Sherman" "06" "County" 3 "48" "295" "Lipscomb" "06
Excel Prompt User on Focus
Excel Prompt User on Focus In this section, you will learn how to prompt user on focusing the cell using Apache POI. EXAMPLE In the below example, you will learn how to prompt user on focusing the cell. Here, the message title
How to check for Empty textboxed and fill it with a value on a button click
How to check for Empty textboxed and fill it with a value on a button... is a code which check for Empty textbox and fill it with a value on a button... should check if it is empty and should get added to the second target text box
Auto fit the MS Excel cell width
Auto fit the MS Excel cell width  I am writing string in ms excel sheet via java code . Cell width is very large, and I want to auto fit the width of cell via java. Kindly help me as soon as possible. Its very urgent
Create Excel(.xlsx) document using Apache POI
Create Excel(.xlsx) document using Apache POI In this section, you will learn how to create a Excel sheet having .xlsx extension using Apache POI library. In the given below example, we will going to create excel document having one
Excel User Define Error Message
Excel User Define Error Message In this section, you will learn , while cell value validation,  how to show user defined error message using Apache POI... than 10,20 or 30, following message will show up : Download Source Code
Excel Validating Value in Range
Excel Validating Value in Range In this section, you will learn how to validate a cell's value within a defined range using Apache POI. EXAMPLE In this below example, you will learn how to validate a cell's value within
Checking Date Value of Excel Cells
the date value contained in a excel cell using Apache POI. Date can have... utility function on cells. Given below the Excel content : Given below the code... = workbook.getSheetAt(0); // // Read a cell the first cell on the sheet
how to create an excel file using java
how to create an excel file using java  how to create an excel file using java
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java