To read a excell sheet we use a library, which comes from a third party
XlsReader-0.1.0, http://bezier.de/processing/libs/xls/
You have to download this library and put it in the right spot, so that Processing can find it.
This is the folder libraries in the Processing folder. In MACOS you have to select the Processing application and ask for the folders contained in it.
Rename the folder in the folder libraries: XlsReader.
Then you can try out an example in the example folder in this folder XlsReader.
import de.bezier.data.*;
XlsReader reader;
int c = 0;
PFont fontA;
void setup ()
{
size (300,100);
reader = new XlsReader( this, "workbook.xls" ); // assumes file to be in the data folder
fontA = loadFont("LucidaBright-Demi-18.vlw");
textFont(fontA, 32);
frameRate(3);
loop();
}
void draw(){
c++;
fill(0,36);
text( reader.getString( 1 + c%3, 0 ) , 10 + random(150), 50 + (c%3)*20 );
println( reader.getString( 1 + c%3, 0 ) );
stroke(155);
if ( c>5 ) { fill(200); rect(0,0,300,100);c=0; }
}
This sketch uses a .xls sheet having three words: ship, u-boat and ufo
reader.getString(x,y ) just reads the value in the cell, x y. For a number use: reader.getInt(x,y ) or reader.getFloat(x,y )That is all there is! Of course numbers in the spreadsheet can be used to position an image, or move an image around.

Aucun commentaire:
Enregistrer un commentaire