I have a ArrayList in an activity that comes from a sqlite query in my database activity. I use an Listadapter to view the ArrayList in a listview. That works fine! But,
//ARRAYLIST WORKS!
ArrayList<HashMap<String, String>> test = controller .getAllpersons(value1,value2);
//LISTADAPTER WORKS!
ListAdapter adapter1 = new SimpleAdapter(Persons.this, test, R.layout.rowsales,
new String[] { "NamesId", "personfirstname","personlastname },
new int[] {R.id.NamesId, R.id.personfirstname,R.id.personlastname});
//DATABASE IS FINE!
public ArrayList<HashMap<String, String>> getAllpersons(String value1,String value2) {
ArrayList<HashMap<String, String>> wordList;
wordList = new ArrayList<HashMap<String, String>>();
String selectQuery = "SELECT * FROM STUFF WHERE personfirstname IS NOT NULL and Date BETWEEN '"
+ value1 + "' AND '" + value2 + "'";
SQLiteDatabase database = this.getWritableDatabase();
Cursor cursor = database.rawQuery(selectQuery, null);
if (cursor.moveToFirst()) {
do {
HashMap<String, String> map = new HashMap<String, String>();
map.put("personnameId", cursor.getString(0));
map.put("personfirstname", cursor.getString(1));
map.put("personlastname", cursor.getString(2));
wordList.add(map);
} while (cursor.moveToNext());
}
database.close();
// return contact list
return wordList;
}
But when I try to create a workbook and save it to my sd what get's printed in the cell is {personfirstname = John, personlastname=doe} I want to print John Doe to the workbook. Can anyone help? FYI I am using Apache POI jar to create a workbook.
for (int i = 0; i < test.size(); i++) {
Row row2 = sheet1.createRow((short) i+3);
c = row2.createCell(0);
System.out.println(test.get(i));
c.setCellValue(test.get(i).toString());
c.setCellStyle(s);
}
Aucun commentaire:
Enregistrer un commentaire