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 7185307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:23:17+00:00 2026-05-28T18:23:17+00:00

i am trying to read an excel file using java. while compiling the program

  • 0

i am trying to read an excel file using java. while compiling the program i am getting error as illegal character. help me to fix this problem. here is the code

import java.io.IOException;
import java.io.*;
import java.util.Iterator;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.usermodel.HSSFRow;



public class Readingexcel {

public static void main(String[] args) {
    try {
         System.out.println("before reading");
        POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("input.xlsx"));
        HSSFWorkbook wb = new HSSFWorkbook(fs);
        HSSFSheet sheet = wb.getSheet("first");

        HSSFRow row;
        HSSFCell cell;
        String s;

        int rows; // No of rows
        rows = sheet.getPhysicalNumberOfRows();
         System.out.println(rows);
         System.out.println(sheet.getRow(1).getPhysicalNumberOfCells());
        int cols = 0; // No of columns
        int tmp = 0;

// This trick ensures that we get the data properly even if it doesn’t start from first few rows
        for (int i = 0; i < 10 || i < rows; i++) {
            row = sheet.getRow(i);

            if (row != null) {
                tmp = sheet.getRow(i).getPhysicalNumberOfCells();


                if (tmp > cols) {
                    cols = tmp;

                }
            }
        }

        for (int r = 0; r < rows; r++) {
            row = sheet.getRow(r);
            if (row != null) {
                for (int c = 0; c < cols; c++) {
                    cell = row.getCell((short) c);
                    if (cell != null) {
// Your code here
// s = cell.getData();
                       System.out.println(cell.getStringCellValue());


                    }
                }
            }
        }
    } catch (Exception ioe) {
        ioe.printStackTrace();
    }

}
}

while compiling the program am getting error like

Microsoft Windows XP [Version 5.1.2600]
 (C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\vino>cd C:\Program Files\jdk1.6.0_10\bin

C:\Program Files\jdk1.6.0_10\bin>javac Readingexcel.java
Readingexcel.java:1: illegal character: \187
import java.io.IOException;
^
Readingexcel.java:1: illegal character: \191
import java.io.IOException;
^
2 errors

can anyone help me to fix this problem.

  • 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-05-28T18:23:18+00:00Added an answer on May 28, 2026 at 6:23 pm

    I am pretty sure that this is BOMs (Byte Order Marks). Make sure you use the correct encoding. Maybe open the file in some other editor and re-save it in order to remove the BOMs. Nodepad ++, for instance, helps you.

    Good luck,
    Max

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to read an excel file using an OleDb Reader, I couldn't debug
I am trying to read in an Excel file using xlrd, and I am
I'm trying to read from excel file with oleDB provider using C#: using (var
Whilst trying to parse MS Excel file using POI-HSSF v3.2 I am getting IndexOutOfBoundsException.
I am Trying to read an Excel file using and finding the Start position
I'm trying to read an Excel (xlsx) file using the code shown below. I
In PHP, I'm trying to read an Excel file using COM(): $rrc_app = new
I'm trying to read an excel file from C# using COM, and can get
I’m trying to read and parse a UTF-8 Excel file using the PHPExcelReader but
I'm trying to read the cells into an excel file without using ole db,

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.