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.
How to resolve this?
"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(...);
I guess that the intention was to call 'statically' the getWorkbook()
method, as you should. So, you should change your wb
member initialization as:
Workbook wb = Workbook.getWorkbook(...)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With