Tải bản đầy đủ - 0 (trang)
Hack 20. Pick a Winner at Random

Hack 20. Pick a Winner at Random

Tải bản đầy đủ - 0trang

platform,too,becauseCommand-C/Vsometimes

invokestheoperatingsystem'sCopy/Pastecommands

ratherthantheonesbuildintoGoogleSpreadsheets.

ButGoogleSpreadsheetshasitsowncopy/paste

handlerswireduptoCtrl-CandCtrl-V,andbecause

thesedon'thaveafunctiononMacOSX,theyaremore

reliable.

Eachcontestantfromthelistnowhasarandomnumbernextto

it,andyoucannowsortthelistbythisnumber.Todoso,click

thedividerlinejustbelowtheRanktogetthesortoptionto

appear.Next,sortthecolumn(itdoesn'tmatterwhetheryou

chooseA-ZorZ-A,becausewhatyou'reafterisarandom

result).Additionally,youcanincludearesultsectionthat

reportsthetopthreecells(using=A2,=A3,and=A4

respectively)toshowthewinners,aspicturedinFigure3-7.

EachtimeyouclicktheSortoption,anewrandomlistof

winnersisgenerated,sincetheRANDfunctioncalculatesanew

valueeverytimeyouperformanaction.

AGoogleSpreadsheetslistofcontestants



Franceneisrandomlypickedasthefirstwinner



Hack21.EmbedYourSpreadsheetina

WebPage

YoucanexportaGoogleSpreadsheettoanembeddableHTML

format,whichyoucanthenincludeinyourblogoranyother

webpage.

Therearedifferentwaystoincludespreadsheetdatainaweb

page,suchasablogposting.Youcanexportthespreadsheetto

HTMLandcopythatintoyourwebsite'sHTMLeditor,for

instance.Thisisagoodquickanddirtywaytodoit,butas

you'llsee,therearebetterways.

Let'sstartwithaspreadsheetlistingalbumreleasesofthe

Beatles,asshowninFigure3-8.



NOTE

IcompiledtheBeatlesdiscographydatawithalittle

helpfromtheGoogleMusicservice,whichyoucanfind

byperformingaGoogle.comwebsearchfor"beatles"

andthenclickingonthealbumimageshowninthe

results.Youcanfindthespreadsheetat

http://spreadsheets.google.com/ccc?

key=pvm6FPiylicL8KMnPUNzCcw—thisisaread-only

viewofthedata,butyoucanmakeacopybychoosing

File Copyspreadsheet.

ToexportthediscographydataasHTML,selectFile Export

HTMLfromtheSpreadsheetsmenu.Anewbrowserwindowwill

open;viewtheHTMLsourceofthepage,andlookforthe

secondopening"table"tag.Copyeverythingfrom(and

including)thistag,upto(andincluding)thecorresponding

closing"table"tag.Ifyou'reusingarichtexteditorforyour

webpageorblog,switchtoHTMLeditingmode(Blogger'sHTML

editingmodeisshowninFigure3-9).Next,pastethetableyou

copiedintotheeditor,asshowninFigure3-9.Figure3-10



showsthespreadsheetdataembeddedinaBloggerblog.



NOTE

IfyoufindthattheHTMLsourceappearsasonelong

line,youcansavetheHTMLfiletoyourharddrive,and

usetheHTMLTidyutility(http://tidy.sourceforge.net)

toformatthesourceinamorehuman-friendlyway.

TheHTMLforthispost,however,isbloated,andalsodoesn't

automaticallyupdatewhenyouupdateyourspreadsheetdata

source.Amoredirectwaytoembedaspreadsheetistochoose

thePublishtabinGoogleSpreadsheetstoclick"Publishnow"

(checkthe"Automaticallyrepublish..."option,too).Youcan

nowselectthe"Morepublishingoptions"linkandinthedialog

thatopens,pick"HTMLtoembedinawebpage,"asshownin

Figure3-11.Afterclicking"GenerateURL,"pastethecode

snippetprovidedtoyouintoyourblog'sHTMLeditorand

publishthepost,asshowninFigure3-12.

Yourspreadsheetdiscography



Usingthe"EditHTML"viewofBlogger,youcanpastethe

HTMLsourcefromanypage



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Hack 20. Pick a Winner at Random

Tải bản đầy đủ ngay(0 tr)

×