1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
public WritableWorkbook createWorkbook(String fileName){
//exports must use a temp file while writing to avoid memory hogging
WorkbookSettings wbSettings = new WorkbookSettings();
wbSettings.setUseTemporaryFileDuringWrite(true);
//get the sdcard's directory
File sdCard = Environment.getExternalStorageDirectory();
//add on the your app's path
File dir = new File(sdCard.getAbsolutePath() + "/JExcelApiTest");
//make them in case they're not there
dir.mkdirs();
//create a standard java.io.File object for the Workbook to use
File wbfile = new File(dir,fileName);
WritableWorkbook wb = null;
try{
//create a new WritableWorkbook using the java.io.File and
//WorkbookSettings from above
wb = Workbook.createWorkbook(wbfile,wbSettings);
}catch(IOException ex){
Log.e(TAG,ex.getStackTrace().toString());
Log.e(TAG, ex.getMessage());
}
return wb;
} |
Partager