Monday, 2 September 2013

Retrive Excel Sheet data into Sqlite Database Android

Retrive Excel Sheet data into Sqlite Database Android

In Android application ,i should get all the datas(nearly 500 coloums and
1000 rows) from Excel Sheet into Sqlite Database. For that i have used the
following code snippet,
FileInputStream is = new FileInputStream("Excel File Path in SDCard");
HSSFWorkbook wb = new HSSFWorkbook(is);
HSSFSheet sheet = wb.getSheet("Test");
Iterator<?> rowIterator = sheet.rowIterator();
int index = 0;
while (rowIterator.hasNext()){
HSSFRow hssfRow = (HSSFRow) rowIterator.next();
if(index++ != 0){
//In this stage i have storing each cell into database
util.inserrDataToSqliteDb(dbManager,
hssfRow.getCell(1).getStringCellValue(),
hssfRow.getCell(2).getStringCellValue()
}
}
When use this code it takes long time to get data from excel sheet. Taking
all the rows without any iteration into database may be a good idea. But i
could not get any reference to do that one.
Any suggestions ? Thanks,

No comments:

Post a Comment