如何允许 Google 电子表格的 "CellFeed" 也可以 return 空白单元格(使用 Java)?

How to allow the "CellFeed" of Google Spreadsheet to return the blank cells as well (using Java)?

以前,我使用 ListFeed 访问 Google 电子表格并获取行。随着行数的增加,我需要转移到 CellFeed 以便批量获取数据。

我在使用 Cell Feed 时遇到问题,Google 电子表格中的空值或空值未被 return 编辑。而当我使用 ListFeed 时,它也用于 return 空白值。

代码如下:

        URL cellFeedUrl2 = new URI(SPREADSHEET_FEED_URL.toString() + "?min-row=2&max-row=5").toURL();  
        CellFeed cellFeed2 = service.getFeed(cellFeedUrl2, CellFeed.class);
        for (CellEntry cell : cellFeed2.getEntries()){  
            System.out.println(cell.getCell().getValue() + "\t");  
        }  

实际输出:
1. 第 1 行
姓名
电子邮件
出生日期
Phone


2. 第 2 行
姓名
电子邮件
Phone


(没有 DOB,因为它在电子表格中是空的,但它仍然应该出现)

预期输出:
1. 第 1 行
姓名
电子邮件
出生日期
Phone

2.Row 2
姓名
电子邮件
出生日期
Phone

求推荐!

解决方法是在URL中增加一个额外的参数如下:

URL cellFeedUrl2 = new URI(SPREADSHEET_FEED_URL.toString() + "?return-empty=true&min-row=2&max-row=5").toURL();  
    CellFeed cellFeed2 = service.getFeed(cellFeedUrl2, CellFeed.class);
    for (CellEntry cell : cellFeed2.getEntries()){  
        System.out.println(cell.getCell().getValue() + "\t");  
    }  

参数"return-empty=true" returns空值为null,因此如果出现异常可以使用try-catch块处理。