Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:29:03+00:00 2026-06-15T09:29:03+00:00

I have an excel file of 111 rows. I need to omit first two

  • 0

I have an excel file of 111 rows. I need to omit first two rows of the sheet and then read the file using java and POI.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:29:04+00:00Added an answer on June 15, 2026 at 9:29 am

    You have to skip first two rows using rownum().Here is the sample code

    HSSFWorkbook      workBook = new HSSFWorkbook (fileSystem);
    HSSFSheet         sheet    = workBook.getSheetAt (0);
    Iterator<HSSFRow> rows     = sheet.rowIterator ();
    
    while (rows.hasNext ())
    {
      HSSFRow row = rows.next ();
      // display row number in the console.
      System.out.println ("Row No.: " + row.getRowNum ());
      if(row.getRowNum()==0 || row.getRowNum()==1){
       continue; //just skip the rows if row number is 0 or 1
      }
    }
    

    Here is the complete example

    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRichTextString;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem; 
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    
    import java.util.Iterator;
    
    public class POIExcelReader
    {
    
    /** Creates a new instance of POIExcelReader */
    public POIExcelReader ()
    {}
    
    @SuppressWarnings ("unchecked")
    public void displayFromExcel (String xlsPath)
    {
    InputStream inputStream = null;
    
    try
    {
    inputStream = new FileInputStream (xlsPath);
    }
    catch (FileNotFoundException e)
    {
    System.out.println ("File not found in the specified path.");
    e.printStackTrace ();
    }
    
    POIFSFileSystem fileSystem = null;
    
    try
    {
    fileSystem = new POIFSFileSystem (inputStream);
    
    HSSFWorkbook      workBook = new HSSFWorkbook (fileSystem);
    HSSFSheet         sheet    = workBook.getSheetAt (0);
    Iterator<HSSFRow> rows     = sheet.rowIterator ();
    
    while (rows.hasNext ())
    {
    HSSFRow row = rows.next ();
    if(row.getRowNum()==0 || row.getRowNum()==1){
           continue; //just skip the rows if row number is 0 or 1
          }
    // once get a row its time to iterate through cells.
    Iterator<HSSFCell> cells = row.cellIterator ();
    
    while (cells.hasNext ())
    {
    HSSFCell cell = cells.next ();
    
    System.out.println ("Cell No.: " + cell.getCellNum ());
    
    /*
     * Now we will get the cell type and display the values
     * accordingly.
     */
    switch (cell.getCellType ())
    {
        case HSSFCell.CELL_TYPE_NUMERIC :
        {
    
            // cell type numeric.
            System.out.println ("Numeric value: " + cell.getNumericCellValue ());
    
            break;
        }
    
        case HSSFCell.CELL_TYPE_STRING :
        {
    
            // cell type string.
            HSSFRichTextString richTextString = cell.getRichStringCellValue ();
    
            System.out.println ("String value: " + richTextString.getString ());
    
            break;
        }
    
        default :
        {
    
            // types other than String and Numeric.
            System.out.println ("Type not supported.");
    
            break;
        }
    }
    }
    }
    }
    catch (IOException e)
    {
    e.printStackTrace ();
    }
    }
    
    public static void main (String[] args)
    {
    POIExcelReader poiExample = new POIExcelReader ();
    String         xlsPath    = "c://test//test.xls";
    
    poiExample.displayFromExcel (xlsPath);
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel file Country.xls. This Excel file contains two sheet/records Country and
I have an excel file which contains 250 sheets( 1st sheet contains 250 rows
I have one excel file (*.xlsm) with VBA code on first sheet: Private Sub
I have an Excel file and I need to read a value from a
We have a excel file with a bunch of sheets. The first sheet is
I have an excel file and I want to read each column and create
I have an excel file that I need to make some changes. I need
I have an Excel file that I need to import into a (new) Oracle
I have an Excel file that gets external data from database table. I need
I have a Excel File, i am able to read single row from Excel

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.