How can I format a Google Sheets spreadsheet cell with the API?

后端 未结 5 1328
小蘑菇
小蘑菇 2020-12-18 09:53

My application generates a table of data and creates a new spreadsheet document in a user\'s Google Drive. How can I add formatting (color, font-weight, width, etc.) to indi

5条回答
  •  失恋的感觉
    2020-12-18 10:27

    Smartsheet utilizes the ability of the Google API to import an Excel file. The code is roughly along these lines:

    DocsService client = new DocsService();
    client.setOAuthCredentials();
    
    DocumentListEntry newEntry = new SpreadsheetEntry();
    newEntry.setMediaSource(new MediaByteArraySource(, DocumentListEntry.MediaType.XLS.getMimeType()));
    newEntry.setTitle(new PlainTextConstruct());
    
    DocumentListEntry insertedEntry = client.insert(new URL("https://docs.google.com/feeds/default/private/full/"), newEntry);
    
    // This is your URL to the new doc
    String docUrl = insertedEntry.getDocumentLink().getHref();
    

    We already had the ability to export a Smartsheet to an Excel file with formatting via Apache POI. Adding export to a Google Spreadsheet was quite simple for us to implement and it provided some additional functionality beyond what you could do via the API.

    Sorry for the delayed response - just happened across this question.

提交回复
热议问题