我想将xls文件数据显示到sq-lite数据库,我不知道那个请帮助我,我已经创建了xls文件并且也读了它但是现在不知道如何显示将数据插入sq-lite中的数据。在下面的代码中,我给出了读取xls文件代码
try
{
InputStream input = new BufferedInputStream(new FileInputStream("/sdcard/raav.xls"));
POIFSFileSystem fs = new POIFSFileSystem( input );
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFSheet sheet = wb.getSheetAt(0);
Iterator rows = sheet.rowIterator();
while( rows.hasNext() )
{ HSSFRow row = (HSSFRow)
rows.next();
System.out.println("\n");
Iterator cells = row.cellIterator();
while( cells.hasNext() )
{
HSSFCell cell = (HSSFCell) cells.next();
if(HSSFCell.CELL_TYPE_NUMERIC==cell.getCellType())
System.out.print( cell.getNumericCellValue()+" " );
else if(HSSFCell.CELL_TYPE_STRING==cell.getCellType())
System.out.print( cell.getStringCellValue()+" " );
else if(HSSFCell.CELL_TYPE_BOOLEAN==cell.getCellType())
System.out.print( cell.getBooleanCellValue()+" " );
else if(HSSFCell.CELL_TYPE_BLANK==cell.getCellType())
System.out.print( "BLANK " );
else
System.out.print("Unknown cell type"); } }}
catch (Exception e) {
}
}
答案 0 :(得分:0)
要在数据库中存储二进制文件,您可以使用BLOB类型并将其传递给byte[]
或使用字符串并在Base64中来回转换。