Created
July 29, 2016 14:28
-
-
Save anonymous/7c1d815b3d134a5be5a0ee505918e2ff to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
workBook = CreateObject( "java", "org.apache.poi.xssf.usermodel.XSSFWorkbook").Init(); | |
sheet = WorkBook.CreateSheet( JavaCast( "string", "my sheetname" ) ); | |
// Simulate rows used in AC4 formula | |
sheet.createRow(0).createCell(0).setCellValue( javacast("float", 5) ); | |
sheet.createRow(1).createCell(0).setCellValue( javacast("float", 7) ); | |
// Simulate AC4 formula | |
sheet.createRow(2).createCell(0).setCellFormula( "SUM(A1:A2)" ); | |
// Simulate cell populated by Oracle date | |
sheet.createRow(3).createCell(0).setCellValue( now() ); | |
// Finally, apply EDATE formula | |
sheet.createRow(4).createCell(0).setCellFormula( "EDATE($A$4,-(A3))" ); | |
// Using binary stream because trycf.com does not support files for security reasons | |
baos = createObject("java", "java.io.ByteArrayOutputStream").init(); | |
workBook.write( baos ); | |
baos.close(); | |
</cfscript> | |
<!--- CF10 lacks support for script version of cfcontent ---> | |
<cfheader name="Content-Disposition" value="inline; filename=test.xlsx"> | |
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" | |
variable="#baos.toByteArray()#"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment