Use Java Excel API to modify an Excel file.
Package modifyexcel;
Import java. Io. file;
Import java. Io. ioexception;
Import jxl .*;
Import jxl. Read. Biff. biffexception;
Import jxl. Write .*;
Public class modifyexcel {
Public static void main (string [] ARGs) throws biffexception, ioexception, writeexception {
Workbook srcxls = Workbook. getworkbook (new file ("E: \ Java-Src \ excelapilearning \ myfile.xls "));
Writableworkbook copy = Workbook. createworkbook (new file ("E: \ Java-Src \ excelapilearning \ output.xls"), srcxls );
Writablesheet sheet1 = copy. getsheet (0 );
Writablecell cell1 = sheet1.getwritablecell (0, 0 );
If (cell1.getcontents (). Length () = 0 ){
Label labelcell = (Label) cell1;
Labelcell. setstring ("Haha ");
}
Label Label = new label (0, 3, "Xixi ");
Sheet1.addcell (Label );
Copy. Write ();
Copy. Close ();
}
}