I cannot insert a header (or any regular data) into a newly created worksheet through the Java API. The standard way to insert data is to provide a header and value, e.g.
newEntry.getCustomElements().setValueLocal(header, value2);
This question, like this one, was sent to stackoverflow:
How to add a title to a Google spreadsheet
The suggested answer was to try to use a channel based on a cellular network, rather than a list based on the above example. I could not do this, since any request for cells or attempts to get a cell feed seems to return 0, since there is no data to return in any cell ... at least this is what I think is happening ...
eg.
public void getCells(){ cellFeedUrl = worksheetEntry.getCellFeedUrl(); CellFeed feed; try { feed = spreadSheetService.getFeed(cellFeedUrl, CellFeed.class); for (CellEntry cell : feed.getEntries()) { System.out.println(worksheetEntry.getTitle().getPlainText()); String shortId = cell.getId().substring(cell.getId().lastIndexOf('/') + 1); System.out.println(" -- Cell(" + shortId + "/" + cell.getTitle().getPlainText() + ") formula(" + cell.getCell().getInputValue() + ") numeric(" + cell.getCell().getNumericValue() + ") value(" + cell.getCell().getValue() + ")"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } } and public void queryHeader(){ CellQuery query = new CellQuery(cellFeedUrl); query.setMinimumRow(1); query.setMaximumRow(1); query.setMinimumCol(1); query.setMaximumCol(1); try { CellFeed feed = spreadSheetService.query(query, CellFeed.class); List<CellEntry> entries = feed.getEntries(); for(CellEntry cell : entries){ cell.changeInputValueLocal("new"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ServiceException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
source share