Merge pull request #2782 from tfmorris/2306-gdata-empty-cells

Fix Google Sheets export with empty cells
This commit is contained in:
Tom Morris 2020-06-22 13:01:23 -04:00 committed by GitHub
commit 6b00c7b602
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -80,9 +80,7 @@ final class SpreadsheetSerializer implements TabularSerializer {
for (int c = 0; c < cells.size(); c++) {
CellData cellData = cells.get(c);
if (cellData != null && cellData.text != null) {
cellDatas.add(cellData2sheetCellData(cellData));
}
cellDatas.add(cellData2sheetCellData(cellData));
}
rowData.setValues(cellDatas);
@ -98,8 +96,12 @@ final class SpreadsheetSerializer implements TabularSerializer {
com.google.api.services.sheets.v4.model.CellData sheetCellData = new com.google.api.services.sheets.v4.model.CellData();
ExtendedValue ev = new ExtendedValue();
ev.setStringValue(cellData.value.toString());
if (cellData == null || cellData.value == null) {
ev.setStringValue("");
} else {
ev.setStringValue(cellData.value.toString());
}
sheetCellData.setUserEnteredValue(ev);
return sheetCellData;

View File

@ -68,6 +68,8 @@ public class UploadCommand extends Command {
private static final String METADATA_DESCRIPTION = "OpenRefine project dump";
private static final String METADATA_ICON_FILE = "logo-openrefine-550.png";
// TODO: We need a way to provide progress to the user during long uploads
@Override
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
@ -99,7 +101,8 @@ public class UploadCommand extends Command {
List<Exception> exceptions = new LinkedList<Exception>();
String url = upload(project, engine, params, token, name, exceptions);
if (url != null) {
// The URL can be non-null even if it doesn't fail
if (url != null && exceptions.size() == 0) {
writer.writeStringField("status", "ok");
writer.writeStringField("url", url);
} else if (exceptions.size() == 0) {