【问题标题】:read excel file with aspose version 2.5使用 aspose 2.5 版读取 excel 文件
【发布时间】:2016-06-17 09:30:54
【问题描述】:

我想用 aspose 2.5 版读取 excel 文件,我知道在最新版本中我们可以这样做: Workbook w = new Workbook(fileStream); Cells cells = w.getWorksheets().get(0).getCells();

我没有找到关于 aspose 2.5 的任何文档。

【问题讨论】:

    标签: aspose aspose-cells


    【解决方案1】:

    请查看以下示例代码及其示例控制台输出。该代码读取源 excel 文件并打印单元格 A1 到 A10 的名称及其值。

    Java

    // Open the workbook with inputstream or filepath
    Workbook wb = new Workbook();
    wb.open("source.xlsx");
    
    // Access first worksheet
    Worksheet ws = wb.getWorksheets().getSheet(0);
    
    // Read cells A1 to A10 and print their values
    for (int i = 0; i < 10; i++) {
        int row = i;
        int col = 0;
    
        // Access the cell by row and col indices
        Cell cell = ws.getCells().getCell(row, col);
    
        // Print cell name and its value
        System.out.println(cell.getName() + ": " + cell.getStringValue());
    }
    

    控制台输出示例

    A1: 13
    A2: 16
    A3: 87
    A4: 73
    A5: 69
    A6: 91
    A7: 59
    A8: 46
    A9: 82
    A10: 54
    

    注意:我在 Aspose 担任开发人员宣传员

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多