Skip to content

Instantly share code, notes, and snippets.

@retrospectacus
Created May 4, 2016 20:45
Show Gist options
  • Save retrospectacus/3c8a4c67debc8dced989752e2d38adc2 to your computer and use it in GitHub Desktop.
Save retrospectacus/3c8a4c67debc8dced989752e2d38adc2 to your computer and use it in GitHub Desktop.
val content = StreamConverters.asOutputStream().mapMaterializedValue { os =>
writeXlsDataToStream(os)
os.close()
}
Ok.chunked(content).as("application/xls").withHeaders(
"Mime-Type" -> "application/xls",
"Content-disposition" -> s"attachment; filename=Report${DateTimeFormat.forPattern("_ddMMMYYYY_HHmmss").print(new DateTime)}.xls"
)
val content = Source.fromPublisher(Streams.enumeratorToPublisher(Enumerator.outputStream { os =>
writeXlsDataToStream(os)
os.close()
} >>> Enumerator.eof))
Ok.chunked(content).as("application/xls").withHeaders(
"Mime-Type" -> "application/xls",
"Content-disposition" -> s"attachment; filename=Report${DateTimeFormat.forPattern("_ddMMMYYYY_HHmmss").print(new DateTime)}.xls"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment