tags:

views:

350

answers:

1
 import java.io.*;
 import jxl.*;
 class Xlparsing
 {
   Workbook wb =wb.getWorkbook(new File(
    "C:\\Documents and Settings\\kmoorthi\\Desktop\\ak\\new.xls"));
   // Illegal forward reference What it means
   Sheet st = wb.getSheet(0);
   Cell cell1 = st.getCell(0,0);
   String a1 = cell1.getContents();
   public static void main(String s[])
   {
     System.out.println(new Xlparsing().a1);
   }
 }

Hi When i tried to extract data from excel sheet illegal forward reference error comes in the file object creation please resolve this . Thanks in Advance

+5  A: 

"Illegal forward reference" means that you are trying to use a variable before it is defined.

In this case, you are trying to invoke a method on wb in the declaration of wb.

Workbook wb = wb.getWorkbook(...);
erickson
Looks like getWorkbook is static in the API so: Workbook wb = Workbook.getWorkbook(...); should do the trick
barrowc
Ah, I Googled around to try to figure out what API he's using but couldn't find an exact match.
erickson