Ignore:
Timestamp:
Nov 1, 2010, 4:38:36 PM (12 years ago)
Author:
adem.bilican@…
Message:

SimpleTox? exporter with file downloading system

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/exporter/ExporterController.groovy

    r1000 r1035  
    8888
    8989        HSSFWorkbook wb = new HSSFWorkbook()
    90         FileOutputStream fileOut = new FileOutputStream(studyInstance.title+"_SimpleTox.xls")
     90        //FileOutputStream fileOut = new FileOutputStream(studyInstance.title+"_SimpleTox.xls")
    9191//        HSSFCellStyle style = wb.createCellStyle()
    9292//        style.setFillForegroundColor((short) HSSFColor.RED.index)
     
    126126            sub.createCell((short)8).setCellValue(studyInstance.samples.getAt(s-1).parentSubject.species.name)
    127127
     128            // adding the subject domain + template properties
    128129            for (u in 0..studyInstance.samples.getAt(s-1).parentSubject.giveFields().unique().size()-1){
    129                 row.createCell((short)9+u).setCellValue(studyInstance.samples.getAt(s-1).parentSubject.giveFields().getAt(u).toString())
    130 //                println "VALUE "+studyInstance.samples.getAt(s-1).parentSubject.getFieldValue(u.name)
    131130                TemplateField tf = studyInstance.samples.getAt(s-1).parentSubject.giveFields().getAt(u)
    132 //                println tf.name
    133 //                println studyInstance.samples.getAt(s-1).parentSubject.giveFields().getAt(u)
    134131                row.createCell((short)9+u).setCellValue(tf.name)
    135132                studyInstance.samples.getAt(s-1).parentSubject.getFieldValue(tf.name) ? sub.createCell((short)9+u).setCellValue(studyInstance.samples.getAt(s-1).parentSubject.getFieldValue(tf.name).toString()) : "not define"
    136133            }
    137134
     135            // adding the samplingEvent domain + template properties
     136            for (t in 0..studyInstance.samples.getAt(s-1).parentEvent.giveFields().unique().size()-1){
     137                TemplateField tf = studyInstance.samples.getAt(s-1).parentEvent.giveFields().getAt(t)
     138                row.createCell((short)9+studyInstance.samples.getAt(s-1).parentSubject.giveFields().unique().size()+t).setCellValue(tf.name)
     139                studyInstance.samples.getAt(s-1).parentEvent.getFieldValue(tf.name) ? sub.createCell((short)9+studyInstance.samples.getAt(s-1).parentSubject.giveFields().unique().size()+t).setCellValue(studyInstance.samples.getAt(s-1).parentEvent.getFieldValue(tf.name).toString()) : "not define"
     140            }
     141
     142            // adding samples domain + template properties
     143            TemplateField sf = studyInstance.samples.getAt(s-1).giveFields().getAt(s)
     144            //println studyInstance.samples.getAt(s-1).getFieldValue(sf.name)
     145
     146            // adding Event domaine + template properties
     147
     148
    138149        }
     150        //println "DOMAINS " +studyInstance.samples.getAt(s-1).parentSubject.giveFields()
    139151
    140         //println "DOMAINS " +studyInstance.samples.getAt(s-1).parentSubject.giveFields()
     152        //wb.write(fileOut)
     153        //fileOut.close()
     154
     155        response.setHeader("Content-disposition", "attachment;filename=\"${studyInstance.title}_SimpleTox.xls\"")
     156        response.setContentType("application/octet-stream")
     157        wb.write(response.outputStream)
     158        response.outputStream.close()
     159
    141160       
    142        
    143         wb.write(fileOut)
    144         fileOut.close()
    145161    }
    146162
     163 
    147164}
Note: See TracChangeset for help on using the changeset viewer.