0

I'm trying to update an existing Excel file. I used the code I saw here Writing to an Existing Excel File but I can't call the function from the main activity.

I tried to create a instance from the department.

It is my code of the class

public class ExceLJxL {

    public ExceLJxL(){

    }

    public static void WriteFile(String path) throws BiffException, IOException, RowsExceededException, WriteException {

        Workbook wb = Workbook.getWorkbook(new File(path));

        WritableWorkbook copy = Workbook.createWorkbook(new File("D:\temp.xls"), wb);
        WritableSheet sheet = copy.getSheet(1);
        WritableCell cell;
        Label l = new Label(1, 1, "");
        cell = (WritableCell) l;
        sheet.addCell(cell);

        copy.write();
        copy.close();
        wb.close();

    }
}

And here I call the function

 ExceLJxL exceLJxL= new ExceLJxl();
 exceLJxL.WriteFile( "path");

But he doesn't know it

Bruno
  • 3,872
  • 4
  • 20
  • 37
Maxima
  • 69
  • 8
  • Where are you calling this function from? – Kristy Welsh Nov 12 '19 at 13:44
  • 1
    Can you clarify what you mean by "he doesn't know it"? Are you getting a specific error message? If so, please add the exact text of the error message to your question. – Jordan Nov 12 '19 at 13:48
  • 1
    `new File("D:\temp.xls")` Are you trying to make a copy on your Windows PC? `D:` is a partition on a Windows PC and unknown by Android OS. – blackapps Nov 12 '19 at 14:09
  • I read from the main activity: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button=findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { ExceLJxL exceLJxL=new ExceLJxl(); exceLJxL.WriteFile( "path"); } }); } – Maxima Nov 12 '19 at 15:36
  • It writes Cannot resolve symbol 'ExceLJxl' – Maxima Nov 12 '19 at 15:40
  • @Maxima, Java is case-sensitive. The name of the class is "ExceLJx**L**", not "ExceLJx**l**" (the final 'L' is upper-case in the class name, but you're using a lower-case 'l' after the `new` keyword). – Jordan Nov 12 '19 at 15:58

0 Answers0