von hol.sten » Mo, 22.01.2007 19:24
Welchen Browser verwendest du? Wenn ich diese Adresse im Firefox in ein neues Tab eintrage, öffnet sich der Download-Dialog. Wenn ich die Adresse im IE 7 in ein neues Tab eintrage, wird mir folgendes im Browser-Fenster angezeigt:
Code: Alles auswählen
"HOG",71.38,"1/22/2007","12:24pm",-0.22,71.60,72.00,71.03,2505900
HOG hat geschrieben:Aber auf direktem Weg liest Calc auch diese URL nicht.
Ich hatte die obigen Links bisher nicht ausprobiert. Also habe ich das mal schnell nachgeholt mit OOo 2.1.0 US und OOo 1.1.5 DE unter Windows XP.
Dann bin ich den obigen Links gefolgt und habe mir folgenden OOo Basic-Code von dort zusammenkopiert und jeweils in den OOo Versionen in einem Spreadsheet als Makro gespeichert und direkt in der OOo Basic IDE ausgeführt:
Code: Alles auswählen
REM ***** BASIC *****
Sub Main()
' Hole den Aktienkurs für die Software AG über die URL
' http://quote.yahoo.com/d/quotes.csv?s=SOW.DE&f=sl1d1t1c1ohgv&e=.csv
Print "Software AG (WKN 330400): ", GetStockPrice( "SOW.DE" )
' Hole den Aktienkurs für die United Internet AG über die URL
' http://quote.yahoo.com/d/quotes.csv?s=UTDI.DE&f=sl1d1t1c1ohgv&e=.csv
Print "United Internet AG (WKN 508903): ", GetStockPrice( "UTDI.DE" )
End Sub
'----------
' This function looks up the price of a stock symbol from yahoo.
' Pass in these parameters:
' cStockSymbol - a string, which is the stock symbol.
' Returns:
' A number which is the price of the stock.
'
Function GetStockPrice( ByVal cStockSymbol As String ) As Double
' Use this URL to get a stock price from Yahoo.
' For example, this URL...
' http://quote.yahoo.com/d/quotes.csv?s=SOW.DE&s=UTDI.DE&f=sl1d1t1c1ohgv&e=.csv
' would return a CSV file with the prices for both Software AG and United Internet AG.
' Similarly, we can form a URL for a single stock, based upon the parameter.
cURL = "http://quote.yahoo.com/d/quotes.csv?s=" + cStockSymbol + "&f=sl1d1t1c1ohgv&e=.csv"
' Open up a new spreadsheet from the above URL.
' Specify the CSV filter with options that decode the CSV format comming back from Yahoo.
' Specify the Hidden property so that the spreadsheet does not appear on the screen.
oCalcDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0,_
Array( MakePropertyValue( "FilterName", "Text - txt - csv (StarCalc)" ),_
MakePropertyValue( "FilterOptions", "44,34,SYSTEM,1,1/10/2/10/3/10/4/10/5/10/6/10/7/10/8/10/9/10" ),_
MakePropertyValue( "Hidden", True ) ) )
' Get the first sheet of the Calc document.
oSheet = oCalcDoc.getSheets().getByIndex( 0 )
' Get the cell B1, which is the stock price. (Row 0, Col 1.)
nValue = oSheet.getCellByPosition( 1, 0 ).getValue()
' Be sure the close the spreadsheet, because it is hidden, and the user cannot close it.
oCalcDoc.close( True )
' Return the value.
GetStockPrice() = nValue
End Function
'----------
' Create and return a new com.sun.star.beans.PropertyValue.
'
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
Und was soll ich sagen: Es läuft ganz ohne Probleme. Bei beiden OOo Versionen. Welche OOo Version bzw. welches Betriebssystem setzt du denn ein?
Regards
hol.sten
[quote="HOG"]Die URL geht auch im Browser nicht. Z.B.
http://quote.yahoo.com/d/quotes.csv?s=HOG&f=sl1d1t1c1ohgv&e=.csv
Hier als Link geht es, aber nicht, wenn die Adresse direkt im Browser eingegeben wird.[/quote]
Welchen Browser verwendest du? Wenn ich diese Adresse im Firefox in ein neues Tab eintrage, öffnet sich der Download-Dialog. Wenn ich die Adresse im IE 7 in ein neues Tab eintrage, wird mir folgendes im Browser-Fenster angezeigt:
[code]"HOG",71.38,"1/22/2007","12:24pm",-0.22,71.60,72.00,71.03,2505900[/code]
[quote="HOG"]Aber auf direktem Weg liest Calc auch diese URL nicht.[/quote]
Ich hatte die obigen Links bisher nicht ausprobiert. Also habe ich das mal schnell nachgeholt mit OOo 2.1.0 US und OOo 1.1.5 DE unter Windows XP.
Dann bin ich den obigen Links gefolgt und habe mir folgenden OOo Basic-Code von dort zusammenkopiert und jeweils in den OOo Versionen in einem Spreadsheet als Makro gespeichert und direkt in der OOo Basic IDE ausgeführt:
[code]REM ***** BASIC *****
Sub Main()
' Hole den Aktienkurs für die Software AG über die URL
' http://quote.yahoo.com/d/quotes.csv?s=SOW.DE&f=sl1d1t1c1ohgv&e=.csv
Print "Software AG (WKN 330400): ", GetStockPrice( "SOW.DE" )
' Hole den Aktienkurs für die United Internet AG über die URL
' http://quote.yahoo.com/d/quotes.csv?s=UTDI.DE&f=sl1d1t1c1ohgv&e=.csv
Print "United Internet AG (WKN 508903): ", GetStockPrice( "UTDI.DE" )
End Sub
'----------
' This function looks up the price of a stock symbol from yahoo.
' Pass in these parameters:
' cStockSymbol - a string, which is the stock symbol.
' Returns:
' A number which is the price of the stock.
'
Function GetStockPrice( ByVal cStockSymbol As String ) As Double
' Use this URL to get a stock price from Yahoo.
' For example, this URL...
' http://quote.yahoo.com/d/quotes.csv?s=SOW.DE&s=UTDI.DE&f=sl1d1t1c1ohgv&e=.csv
' would return a CSV file with the prices for both Software AG and United Internet AG.
' Similarly, we can form a URL for a single stock, based upon the parameter.
cURL = "http://quote.yahoo.com/d/quotes.csv?s=" + cStockSymbol + "&f=sl1d1t1c1ohgv&e=.csv"
' Open up a new spreadsheet from the above URL.
' Specify the CSV filter with options that decode the CSV format comming back from Yahoo.
' Specify the Hidden property so that the spreadsheet does not appear on the screen.
oCalcDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0,_
Array( MakePropertyValue( "FilterName", "Text - txt - csv (StarCalc)" ),_
MakePropertyValue( "FilterOptions", "44,34,SYSTEM,1,1/10/2/10/3/10/4/10/5/10/6/10/7/10/8/10/9/10" ),_
MakePropertyValue( "Hidden", True ) ) )
' Get the first sheet of the Calc document.
oSheet = oCalcDoc.getSheets().getByIndex( 0 )
' Get the cell B1, which is the stock price. (Row 0, Col 1.)
nValue = oSheet.getCellByPosition( 1, 0 ).getValue()
' Be sure the close the spreadsheet, because it is hidden, and the user cannot close it.
oCalcDoc.close( True )
' Return the value.
GetStockPrice() = nValue
End Function
'----------
' Create and return a new com.sun.star.beans.PropertyValue.
'
Function MakePropertyValue( Optional cName As String, Optional uValue ) As com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function [/code]
Und was soll ich sagen: Es läuft ganz ohne Probleme. Bei beiden OOo Versionen. Welche OOo Version bzw. welches Betriebssystem setzt du denn ein?
Regards
hol.sten