Java to Google Spreadsheet

前端 未结 5 1879
谎友^
谎友^ 2021-02-06 07:59

I was trying to do programming using Java to connect to Google Spreadsheet to do data retrieval or modifying data in the cells.

My Google spreadsheet link is https://doc

5条回答
  •  旧时难觅i
    2021-02-06 08:38

    The feed you get from that URL is a WorksheetFeed, not a SpreadsheetFeed. Try this:

        SpreadsheetService service = new SpreadsheetService("google-spreadsheet");
    
        FeedURLFactory urlFactory = FeedURLFactory.getDefault();
        WorksheetFeed worksheetFeed = service.getFeed(urlFactory.getWorksheetFeedUrl("1V4jT4vSqmY4YNY1VJhariLRLbxfFWf5z8bSTpDcSBPE", "public", "full"), WorksheetFeed.class);
        List worksheets = worksheetFeed.getEntries();
        WorksheetEntry worksheet = worksheets.get(0);
        System.out.println(worksheet.getTitle().getPlainText());
    

提交回复
热议问题