這是我認爲我們甚至可以接近電子表格API的唯一方法。這是不完整的代碼,這是我寫了一個函數內,但你得到的漂移......這是在C#:
與例如工作:
--row 1 = header row
--row 2 = data
--row 3 = data
--row 4 = totally blank
--row 5 = data
--row 6-100 = totally blank
英文:
獲取工作表的ListFeed.Entries.Count。 ListFeeds忽略標題行,因此在此示例中計數爲「2」。
獲取工作表的CellFeed以循環訪問單元格。 CellFeeds DO包含標題行作爲第1行,因此在該示例中,從CellFeed的角度來看,第一個空白行必須是第4行(標題= 1,然後是2個數據行,然後是終止ListFeed集的第一個空白行)因此,我們應該開始通過細胞在第5行及以後尋找任何單元格不爲空:
foreach (WorksheetEntry entry in wsFeed.Entries)
{
//Get the worksheet CellFeed:
CellQuery cellQuery = new CellQuery(entry.CellFeedLink);
CellFeed cellFeed = service.Query(cellQuery);
//Get the worksheet ListFeed to compare with the CellFeed:
AtomLink listFeedLink = entry.Links.FindService(
GDataSpreadsheetsNameTable.ListRel, null
);
ListQuery listQuery = new ListQuery(listFeedLink.HRef.ToString());
//need to have service object already created for this... see API docs
ListFeed listFeed = service.Query(listQuery);
//Now to check if there is data after the ListFeed
//set which would indicate a blank line in the data set (not allowed)
foreach (CellEntry cell in cellFeed.Entries)
{
//start looking in cells in the row after what would be the first blank row
if (cell.Row > listFeed.Entries.Count + 2)
{
if (cell.Value != "")
{
MessageBox.Show("ERROR: There appears to be a blank row +
in the middle of the data set in worksheet: " +
entry.Title.Text + ". Completely blank rows " +
"are not allowed in between data rows. Each row " +
"within the data set must have at least one " +
"value in at least one cell. There CAN and " +
"should be blank rows after the data set at " +
"the bottom of the worksheet.");
return false;
}
}
}
}