Accessing Excel sheets

Lex Spoon lex at
Sat Jun 26 16:00:27 UTC 2004

Guenther Schmidt < at> wrote:
> I had hoped there would be a way to access at least the data from the 
> excel sheets directly via squeak without the need to convert the files 
> first.
> At this time I rather doubt I'd be able to write my own parser for excel 
> sheets in squeak ;-). I had hoped somebody already had.

Excel is probably hard, but CSV should be simple.  Something similar,
but not exactly like this, should get you going:

	file := FileStream readOnlyFileNamed: 'myfile.csv'.
	lines := OrderedCollection new.
	file upToEnd linesDo: [ :l | lines add: l ].
	cells := lines collect: [ :l | l findTokens: ',' ].

Assuming file is the input file, the above should result in cells having
one entry per row of the spreadsheet, and each entry should be a
collection of strings.

(I've simplified the code a bit, assuming that either your file doesn't
have have blank cells or that Excel will at least put a space in for
blank cells....  If both of these are falso then the code needs a little
more tinkering.)

Anyway, try the above in a workspace and then do "explore it" on file,
lines, and cells.


More information about the Squeak-dev mailing list