filmov
tv
How to create Excel file from ListView data and save it in Download directory from your Android app?

Показать описание
This video shows the steps to create an excel file from the ListView data. In this demo it first creates the ListView with some sample string data.
Then in the button onClick method, it reads the listView data one by one iteratively and populate the respective cells of an excel file.
It then saves the file in download folder using the StorageManager APIs.
Complete source code and other details/ steps of this video are posted in the below link:
However, the main Java code is copied below also for reference:
public class MainActivity extends AppCompatActivity {
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
String[] stringArray = {"This", "is", "an", "example", "Excel", "Sheet", "from", "programmer", "world"};
stringArray));
}
public void buttonCreateExcelFile(View view){
HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
}
saveWorkBook(hssfWorkbook);
}
private void saveWorkBook(HSSFWorkbook hssfWorkbook){
StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
try {
FileOutputStream fileOutputStream = new FileOutputStream(fileOutput);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
--
Then in the button onClick method, it reads the listView data one by one iteratively and populate the respective cells of an excel file.
It then saves the file in download folder using the StorageManager APIs.
Complete source code and other details/ steps of this video are posted in the below link:
However, the main Java code is copied below also for reference:
public class MainActivity extends AppCompatActivity {
private ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
String[] stringArray = {"This", "is", "an", "example", "Excel", "Sheet", "from", "programmer", "world"};
stringArray));
}
public void buttonCreateExcelFile(View view){
HSSFWorkbook hssfWorkbook = new HSSFWorkbook();
}
saveWorkBook(hssfWorkbook);
}
private void saveWorkBook(HSSFWorkbook hssfWorkbook){
StorageManager storageManager = (StorageManager) getSystemService(STORAGE_SERVICE);
try {
FileOutputStream fileOutputStream = new FileOutputStream(fileOutput);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
--
Комментарии