2015-11-19 51 views

回答

0

這是可能的,但您需要將文檔作爲提要來收集工作表ID。

$document = "<Google_Sheets_Document_Id>" 

$ns = @{n="http://www.w3.org/2005/Atom"} 
$feedXml = [xml](Invoke-WebRequest -Uri "https://spreadsheets.google.com/feeds/worksheets/$document/public/full").Content 

$entries = Select-Xml -Xml $feedXml -Namespace $ns -XPath "/n:feed/n:entry" 
foreach ($e in $entries) 
{ 
    $href = Select-Xml -Xml $e.Node -XPath "n:link[@type='text/csv']/@href" -Namespace $ns 
    $query = ([System.Uri]"$($href.Node.Value)").Query.Replace("format", "output") 

    $e.Node.title #Sheet title 
    "https://docs.google.com/spreadsheets/d/$document/pub$query" #Sheet URL 
} 

這將下載Atom訂閱源,並從XML文檔中檢索各個CSV文件的工作表標題和URL。

+0

醜陋的代碼,但你明白了。 – saltface