我在我的 android 应用程序中使用 aspose.cell 库来创建 excel 表作为 sdcard 中的输出。
这是我的代码:
void insertData() throws Exception {
//Get the SD card path
String sdPath = Environment.getExternalStorageDirectory().getPath() + File.separator;
Workbook wb = new Workbook();
Worksheet worksheet = wb.getWorksheets().get(0);
Cells cells = worksheet.getCells();
ArrayList<String> arr = new ArrayList<String>();
arr.add("one");
arr.add("two");
arr.add("three");
int i = 0;
for(String value : arr){
//Put some values into cells
//Log.i("rubanraj", value);
Cell cell = cells.get("A"+String.valueOf(++i)); //for A1,A2,A3...
cell.putValue(value);
}
wb.save(sdPath + "Cells_InsertRowsAndColumns.xlsx",SaveFormat.XLSX);
}
我在arrayList中有一组数据,因为最后我需要将这些值插入到我的工作表中的列中。为此,我使用了一个 for 循环从工作表中获取单元格位置,如 A1、A2、A3 .. 并一一插入数据。一切都很好,但我之前没有使用过 aspose lib,所以我不太了解。实际上我在这里需要的是,如何使用这个 aspose.cell 库将值的数组列表直接插入到 excel 表中的 (A,B,C...) 之类的列中?
在这里,我将提供一些我为这项工作引用的链接。
https://github.com/asposecells/Aspose_Cells_Android
我已经尝试过 apache POI 和 jxl 库,但与其他库相比,我觉得 aspose 易于使用。