2012-08-15 2 views
3

모든 단일 셀을 검색하지 않고도 C#을 사용하여 Google 스프레드 시트의 특정 셀에 쓰기를 시도하고 올바른 셀인지 확인할 필요가 있습니다. 예를 들어 A1에 쓰려면 워크 시트의 모든 셀 제목에 "A1"이 있는지 검색하지 않아도됩니다. 다른 프로그래밍 언어 (파이썬)에서이 작업을 수행하는 방법에 대한 많은 예제를 발견했지만 C#에서 동일한 메서드를 찾을 수 없습니다.C# google 스프레드 시트가 특정 셀에 입력 됨

cell[1,1].value = "JoMama"; 
+0

당신이 여기에있는 .NET 라이브러리를 사용하고 있습니까 : 어떻게 그런 짓을 할 수 있습니까? http://code.google.com/p/google-gdata/ – dana

+1

예, 사용하고 있습니다. 나는 그 해답을 찾았습니다. CellFeed.Entries 배열에 멤버가 하나만 있도록 CellQuery의 열과 행의 최소값과 최대 값을 동일하게 설정해야합니다. 그런 다음 그 회원에게 접속하십시오. (아래 코드 참조) – carlilelance

답변

4
/// <summary> 
    /// Updates a single cell in the specified worksheet. 
    /// </summary> 
    /// <param name="service">an authenticated SpreadsheetsService object</param> 
    /// <param name="entry">the worksheet to update</param> 
    private static void UpdateCell(SpreadsheetsService service, WorksheetEntry entry) 
    { 
     AtomLink cellFeedLink = entry.Links.FindService(GDataSpreadsheetsNameTable.CellRel, null); 
     CellQuery query = new CellQuery(cellFeedLink.HRef.ToString()); 
     Console.WriteLine(); 

     Console.Write("Row of cell to update? "); 
     string row = Console.ReadLine(); 

     Console.Write("Column of cell to update? "); 
     string column = Console.ReadLine(); 

     query.MinimumRow = query.MaximumRow = uint.Parse(row); 
     query.MinimumColumn = query.MaximumColumn = uint.Parse(column); 

     CellFeed feed = service.Query(query); 
     CellEntry cell = feed.Entries[0] as CellEntry; 

     Console.WriteLine(); 
     Console.WriteLine("Current cell value: {0}", cell.Cell.Value); 
     Console.Write("Enter a new value: "); 
     string newValue = Console.ReadLine(); 

     cell.Cell.InputValue = newValue; 
     AtomEntry updatedCell = cell.Update(); 

     Console.WriteLine("Successfully updated cell: {0}", updatedCell.Content.Content); 
    } 
+0

http://code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/spreadsheets/spreadsheetdemo.cs – carlilelance