Hey Christopher,

As you've noticed, you can add rows to the end of a worksheet using the
worksheets feed.

First, let's look at what happens at the protocol level.  To add rows to the
end of a sheet, I send the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<entry xmlns="http://www.w3.org/2005/Atom"; xmlns:gs="
http://schemas.google.com/spreadsheets/2006"; xmlns:gd="
http://schemas.google.com/g/2005";
gd:etag="&quot;VUwLVg1QAit7ImBvGV4.&quot;">
<category scheme="http://schemas.google.com/spreadsheets/2006"; term="
http://schemas.google.com/spreadsheets/2006#worksheet"/>
<title>Sheet1</title>
<gs:rowCount>5</gs:rowCount>
<gs:colCount>20</gs:colCount>
</entry>

To the following URL:
https://spreadsheets.google.com/feeds/worksheets/SPREADSHEET_KEY/private/full/WORKSHEET_ID

I verified this just now, and it works great.

Now, to do this in the .NET client library, first fetch the worksheet you
want to update, then make your changes, and finally send the update.

WorksheetQuery query = new WorksheetQuery(SPREADSHEET_KEY, "private",
"full");
WorksheetFeed feed = service.Query(query);
foreach (WorksheetEntry worksheet in feed.Entries)
{
  if (worksheet.Title.Text == "Sheet1") {
    worksheet.Cols = 50;
    worksheet.Rows = 50;
    worksheet.Update();
  }
}

I also just verified this with my own sheet, and it worked great.

This is documented here:
http://code.google.com/apis/spreadsheets/data/2.0/developers_guide_dotnet.html#UpdatingWorksheets

But is still applicable for version 3.0 of the API.

Thanks!
-Vic



On Wed, Dec 8, 2010 at 4:23 PM, Christopher Weeks <[email protected]> wrote:

> Moved from <a href="
> http://www.google.com/support/forum/p/apps-apis/thread?tid=608664f1edbdbc44&hl=en";>the
> old forum</a> (thanks for the pointer, Vic):
>
> When I'm manually handling a worksheet, there is a finite set of rows (100
> on a new sheet) with a button at the bottom to add a number (20 by default)
> empty rows to the bottom.
> I have code that uses cell-based feeds to read and write cell (CellEntry)
> values -- this all works fine.  When I attempt to write to the next row, off
> the bottom of the sheet, I get an error.  I guess I was expecting it to just
> generate the row dynamically, but it makes some sense that that's not how it
> works.  I spent time looking for how to make the CellFeed create new rows
> before figuring out that it's supposed to be done at the worksheet-feed
> level.
> But now, I'm at another impasse.  I find stuff like "To change the metadata
> of a worksheet, begin by getting the desired worksheet from the worksheet
> feed. Then send a PUT request with the desired entry contents to the URL
> provided in an edit link. The edit URL is highlighted in the XML below." but
> I'm not sure how to translate that into using the .NET DLLs.  It looks like
> changing the rowCount should be just like changing the title, but I'm not
> seeing properties and methods to enable that.  E.g., I can do the following
> (wso.Worksheet is an AtomEntry from the WorksheetFeed):
>         wso.Worksheet.Title = New
> AtomTextConstruct(AtomTextConstructElementType.Title, "rename back to
> Sheet1")
>         wso.Worksheet.Update()
> But there is nothing analogous for rowCount.
> Getting to this point has involved *a lot* of trial and error; moving up or
> down a level in the feed/object hierarchy in order to find the right place
> to hook the data, but I'm just not finding what I need this time.
> I appreciate any help you can provide!
>
>
>

Reply via email to