creer excel au chargement
Bonjour, au chargment de mon application endroid je voudrais que ma fonction excel s'execute, docn j'ai fait cela
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
package com.contact;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
createExcel();
Log.d("TAG", "Message");
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void createExcel(){
JavaExcelWrite myExcel = new JavaExcelWrite();
myExcel.createExcel();
}
} |
et voici ma classe JavaExcelWrite();
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| package com.contact;
import java.io.File;
import java.io.IOException;
import java.util.Date;
import jxl.*;
import jxl.write.*;
import jxl.write.Boolean;
import jxl.write.Number;
import jxl.write.biff.RowsExceededException;
public class JavaExcelWrite {
public void createExcel(){
try {
File exlFile = new File("F:/write_test.xls");
WritableWorkbook writableWorkbook = Workbook
.createWorkbook(exlFile);
WritableSheet writableSheet = writableWorkbook.createSheet(
"Sheet1", 0);
//Create Cells with contents of different data types.
//Also specify the Cell coordinates in the constructor
Label label = new Label(0, 0, "Label (String)");
DateTime date = new DateTime(1, 0, new Date());
Boolean bool = new Boolean(2, 0, true);
Number num = new Number(3, 0, 9.99);
//Add the created Cells to the sheet
writableSheet.addCell(label);
writableSheet.addCell(date);
writableSheet.addCell(bool);
writableSheet.addCell(num);
//Write and close the workbook
writableWorkbook.write();
writableWorkbook.close();
} catch (IOException e) {
e.printStackTrace();
} catch (RowsExceededException e) {
e.printStackTrace();
} catch (WriteException e) {
e.printStackTrace();
}
}
} |
mais rien ne fonctionne, je suis nouveau dans l'environne ment android mais c'est le mm system que le codage en java, et je n'arrive pas a mettre de message dans la console pour voir si mes fonction s'exécute bien.
Une idée les amis
Merci