[Seaside] Generate Excel documents from Seaside (Pharo)

Tobias Pape Das.Linux at gmx.de
Mon Feb 3 22:17:33 UTC 2014


On 03.02.2014, at 22:23, Esteban A. Maringolo <emaringolo at gmail.com> wrote:

> Thanks for all your responses.
> 
> I'll take a look into Tobias' work. It is the kind of solution I'm
> interested in. If I can "untie" it from Magritte, then better. :)
> 

Sure, just don’t load Sheet-magritte :)
(haha, I know. I just now splitted Sheet into 3 packages.
Just load Sheet-Core.)

And then do something like this:

self requestContext respond: [:response |
  response
    doNotCache;
    attachmentWithFileName: 'name.xml';  
    contentType: (WAMimeType main: 'application' sub: 'xml');
    nextPutAll: (
      ((WABuilder on: ShSpreadsheetCanvas)
        rootClass: ShSpreadsheetRoot;
        documentClass: WAXmlDocument;
        yourself)
          fullDocument: true;
	  rootBlock: [ :root | " nothing, or what you want... " ];
	  render: [ :sheet | "this is a spreadsheet canvas"
            sheet workbook with: [
              sheet documentProperties: [
		sheet 
                  author: 'esteban';
                  created: (String streamContents: [:stream | |now|
                    now := DateAndTime now.
                    GRPrinter isoDate print: now on: stream.
                    stream nextPut: $T.
                    GRPrinter isoTime print: now on: stream.
                    stream nextPut: $Z]);
                  version: '12.00'].
              sheet excelWorkbook: [
                (sheet tag: 'WindowHeight') with: '6795'.
                (sheet tag: 'WindowWidth') with: '8460'.
                (sheet tag: 'WindowTopX') with: '120'.
                (sheet tag: 'WindowTopY') with: '15'.
                (sheet tag: 'NoAutorRecover').
                (sheet tag: 'ProtectStructure') with: 'False'.
                (sheet tag: 'ProtectWindows') with: 'False'].
              sheet styles: [ "do whatever style you need here" ].
              sheet worksheet
                name: 'sheet 1';
                with: [
                  sheet table
                    fullColumns: 1;
                    fullRows: 1;   
                    expandedRowCount: 42;
                    expandedColumnCount: 34;  	
                    with: [ "example data." | heads |
                        heads := #( 'Title' 'First Name' 'Last Name' 'Email' 'Homepage' 'Phone').
                        heads do: [:header | sheet column caption: header; style: #header].
                        sheet row: [
                          heads do: [:header |
                            sheet cell
                              style: #header;
                              with: [sheet data: [sheet text: header greaseString]]]].
                       #(
                        #( 'Mr.' 'James' 'Bond' '007 at mi5.gov.uk' 'bond.mi5.gov.uk' '0044 12345 007' )
                        #( 'Herr' 'Ernst Stavro' 'Blofeld' 'herrblo at spectreboese.de' 'herrbloboese.de' '0049 30 1234567' )
                        #( 'Dr.' 'Julius' 'No' 'juluno at edel.de' nil '0049 30 987654321' )
                        #( nil 'Francisco' 'Scaramanga' 'franci at scara.it' nil '0039 12 3456 781')
                      ) do: [:dataLine | 
                        sheet row: [ 
                          dataLine do: [:datum |  
                            sheet cell
                              style: #default;
                              with: [
                                datum ifNotNil: [
                                  sheet data
                                    with: [sheet text: datum greaseString]]]]]]]]]]
)]


:D

HTH!

Best
	-Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 1625 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.squeakfoundation.org/pipermail/seaside/attachments/20140203/2a3bca62/signature-0001.pgp


More information about the seaside mailing list