如何将xls文件数据存储到sqlite数据库
问题描述:
我想将xls文件数据显示为sq-lite数据库,我对此没有想法,请帮助我,我已创建xls文件并且还读取它但不要“T现在如何展示这些数据插入数据sq-lite.In下面的代码我已经给读xls文件代码如何将xls文件数据存储到sqlite数据库
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) {
}
}
答
要存储二进制文件的DB您可以使用BLOB类型,通过它byte[]
或使用字符串和来自Base64来回转换。
+0
请问您能否详细说明我的例子... – Ravi 2014-10-05 12:43:09
不清楚你想要什么。你想直接存储XLS文件还是将其转换为表格? – m0skit0 2014-09-30 07:48:55
我想直接存储为sq-lite数据库 – Ravi 2014-10-04 09:37:22