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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
| /////////////////Variable
final int mois = d.getMonth() + 1;
final int annees = d.getYear() - 100;
final int jours = d.getDate();
final String datesok = jours + "." + mois + "." + annees;
// check if available and not read only
if (!isExternalStorageAvailable() || isExternalStorageReadOnly()) {
Log.w("FileUtils", "Storage not available or read only");
return false;
}
boolean success = false;
//New Workbook
// Create a path where we will place our List of objects on external storage
// File file = new File(context.getExternalFilesDir(null), fileName);
FileOutputStream os = null;
FileInputStream file = null;
try {
file = new FileInputStream(new File(context.getExternalFilesDir(null), fileName));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
HSSFWorkbook wb = null;
try {
wb = new HSSFWorkbook(file);
} catch (IOException e) {
e.printStackTrace();
}
// Workbook wb = new HSSFWorkbook();
Cell c = null;
//New Sheet
HSSFSheet sheet1 = wb.getSheetAt(0);
//Sheet sheet1 = null;
//sheet1 = wb.createSheet("Intervention2");
/////////////////
/////////////////
// Generate column headings
int rownum = sheet1.getLastRowNum()+1;
//////////////////////////////
//Update the value of cell
// Row row = sheet1.getRow(0);
// row.createCell(3).setCellValue("Value 2");
/////////////////////////////////
Row row = sheet1.createRow(rownum);
//Row row1 = sheet1.createRow(1);
////////////////////////////////////////////////A faire Ici
///Conteur du nombre de cell
int counter =0;
//String Cellule(counter);
Iterator<Row> rowIter = sheet1.rowIterator();
ArrayList<String> ArrayFichier=new ArrayList<String>();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_multiple_choice, ArrayFichier);
liste.setAdapter(adapter);
///////Fin de la créatuon de la listeview
while (rowIter.hasNext()) {
ArrayList<String> ArrayLigne=new ArrayList<String>();
//Création de la row
HSSFRow myRow = (HSSFRow) rowIter.next();
//HSSFRow test =(HSSFRow) rowIter.next()+1;
Iterator<Cell> cellIter = myRow.cellIterator();
while (cellIter.hasNext()) {
//String tableauChaine[] = {String.valueOf(counter),String.valueOf(counter), "chaine3" , "chaine4"};
HSSFCell myCell = (HSSFCell) cellIter.next();
Log.w("FileUtils", "Cell Value: " + myCell.toString());
//////////////////////test
if(counter < 11){
ArrayLigne.add (String.valueOf(myCell));
counter++;
}else{
ArrayFichier.add (String.valueOf(ArrayLigne));
counter =0;
}
///////////////////////////////
//Ajout des données dans l'arraylist
// ArrayFichier.add (String.valueOf(myCell));
// Affichage du contenue du tableau
//Céation des items du lsitview
//android.R.layout.
}
}
return success;
} |
Partager