Some snippets of a working glamour application loading excel files (Moose 4.8)
MNU on SmallInteger could be a broken VM
A separate class to represent the csv file, storing the rows:
ANExcelModel >> on: aFilename
� � � � ^self new
� � � � � � � � rows: (NeoCSVReader on: (FileSystem root / aFilename) readStream) upToEnd ;
� � � � � � � � yourself
The domain model has an announcer letting the browser know when something changed
AModel>loadFrom: aFileName
� � � � |excel regel � �|
� � � � excel := ANExcelModel on: aFileName .
� � � � excel rows allButFirstDo: [ :row |
� � � � � � � � regel := ANRegel new.
� � � � � � � � regel thema: (self findIn: row at: 1 key: #thema).
� � � � � � � � regel onderwerp: (self findIn: row at: 3 key: #onderwerp).
� � � � � � � � regel addTo: self.
� � � � � � � � �].
� � � � self announce: ANChanged
ANModel>announce: anAnnouncement
� � � � ^self announcer announce: anAnnouncement
Part of the browser construction, loading a file:
� � � � browser transmit to: #thema; andShow: [ :a |
� � � � � � � � a list
� � � � � � � � � � � � title: 'Themas';
� � � � � � � � � � � � display: [ (self model dimensies at: #thema) items ];
� � � � � � � � � � � � updateOn: SVChanged from: SVModel default announcer;
� � � � � � � � � � � � act: [ : b | self loadExcel ] entitled: 'Laad csv';
� � � � � � � � � � � � selectionAct: [ :list |
� � � � � � � � � � � � � � � � self addOnderwerpTo: list selection]
� � � � � � � � � � � � � � � � on: $o
� � � � � � � � � � � � � � � � entitled: 'Voeg onderwerp toe'.
� � � � � � � � a text
� � � � � � � � � � � � title: '?';
� � � � � � � � � � � � display: [ self helpThema ].
� � � � � � � � � � � � ].
ANBrowser>loadExcel
� � � � |excel|
� � � � excel := MorphicUIManager new chooseFullFileName: �'Selecteer een .csv bestand' extensions: nil path: nil preview: nil.
� � � � excel isEmptyOrNil ifFalse:[
� � � � � � � � self model loadFrom: excel]