Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

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

Ads

 
 

Share on Google+Share on Google+

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)      6 years and 5 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.........

Ads
View Answers
Ads









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
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
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
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 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
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
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
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 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
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
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
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 an excel file using java
how to create an excel file using java  how to create an excel file using java
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
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
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
How to upload a large excel file - JSP-Servlet
How to upload a large excel file   Dear sir , How to upload a large excel file and how to read a that large excel file or how to get a each... but for large file my code is not working so please help me sir i have used u r
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
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 to read excel contents when uploaded
How to read excel contents when uploaded  I am working on a project where the user uploads his excel file. Jsp page must read the excel contents... file must be read and the contents must be displayed on the screen. How
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
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 read values from excel sheet and compare with database using jsp
how to read values from excel sheet and compare with database using jsp  hi sir i am arun how to read values from excel sheet and compare with database using jsp coding i.e, if i have 6(assetid,assetname,serialno,cubical
How to Read a file line by line using BufferedReader?
How to Read a file line by line using BufferedReader?  Hello Java... to Read a file line by line using BufferedReader, efficiently and using less memory... at a time very efficiently. View the detailed example and code at Java Read File Line
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java