SHARE
TWEET

Untitled

a guest Jun 19th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rCell = readCell.getContents();
  2. float testnumber = Float.parseFloat(rCell);
  3.      
  4. AssetManager assetManager = getAssets();
  5. InputStream inputStream = null;
  6.   try {
  7.       inputStream = assetManager.open("MyFile.xls");
  8.       } catch (IOException e) {
  9.       e.printStackTrace();
  10.       }
  11. try {
  12.     readAsset = Workbook.getWorkbook(inputStream);
  13.     } catch (IOException e) {
  14.     e.printStackTrace();
  15.     } catch (BiffException e) {
  16.     e.printStackTrace();
  17.     }
  18. Sheet s = readAsset.getSheet(0);
  19.      
  20. Fnamexls="testfile"  + ".xls";
  21.     File sdCard = Environment.getExternalStorageDirectory();
  22.     directory = new File (sdCard.getAbsolutePath() + "/MyFolder");
  23.     directory.mkdirs();
  24.     sdFile = new File(directory, Fnamexls);
  25.  
  26.         wbSettings = new WorkbookSettings();
  27.         wbSettings.setLocale(new Locale("en", "EN"));
  28.         try {
  29.             wrWorkbook = Workbook.createWorkbook(sdFile, wbSettings);
  30.             writeSheet = wrWorkbook.createSheet("First Sheet", 0);
  31.             int row = s.getRows();
  32.             int col = s.getColumns();
  33.             //xx = "";
  34.             for (int c = 0; c < col; c++) {
  35.                 for (int r = 0; r < row; r++) {
  36.                     Cell z = s.getCell(c, r);
  37.                     xx = z.getContents();
  38.                     Label label4 = new Label(c, r, String.valueOf(xx));
  39.                     try {
  40.                         writeSheet.addCell(label4);
  41.                     } catch (RowsExceededException e) {
  42.                         // TODO Auto-generated catch block
  43.                         e.printStackTrace();
  44.  
  45.                     } catch (WriteException e) {
  46.                         // TODO Auto-generated catch block
  47.                         e.printStackTrace();
  48.  
  49.                     }
  50.                 }
  51.             }
  52.             wrWorkbook.write();
  53.             try {
  54.                 wrWorkbook.close();
  55.             } catch (WriteException e) {
  56.                 // TODO Auto-generated catch block
  57.                 e.printStackTrace();
  58.  
  59.             }
  60.             //createExcel(excelSheet);
  61.         } catch (IOException e) {
  62.             // TODO Auto-generated catch block
  63.             e.printStackTrace();
  64.  
  65.         }
  66.  
  67.     readTest();
  68.  
  69. public void readTest(){
  70. Workbook m_workBook = null;
  71. try {
  72.     m_workBook = Workbook.getWorkbook(sdFile);
  73.     } catch (IOException e) {
  74.     e.printStackTrace();
  75.     } catch (BiffException e) {
  76.     e.printStackTrace();
  77.     }
  78. readSheet = m_workBook.getSheet(0);
  79. int rRow = readSheet.getRows();
  80. int rCol = readSheet.getColumns();
  81. Cell readCell = readSheet.getCell(2, 0);
  82. rCell = readCell.getContents();
  83.  
  84. float testnumber = Float.parseFloat(rCell); //Line error  
  85.  
  86. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top