Created
April 23, 2010 17:54
-
-
Save rip747/376892 to your computer and use it in GitHub Desktop.
using java to create an excel spreadsheet
This file contains hidden or 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.hssf.usermodel.HSSFWorkbook").init(); | |
newSheet = workBook.createSheet(); | |
workBook.setSheetName(0, "1"); | |
count = 0; | |
</cfscript> | |
<cfloop array="#headers#" index="i"> | |
<cfscript> | |
row = newSheet.createRow(0); | |
cell = row.createCell(count); | |
cell.setCellValue(i); | |
count = count + 1; | |
</cfscript> | |
</cfloop> | |
<cfloop from="1" to="#arrayLen(data)#" index="i"> | |
<cfscript> | |
row = newSheet.createRow(i); | |
count = 0; | |
</cfscript> | |
<cfloop array="#data[i]#" index="d"> | |
<cfscript> | |
cell = row.createCell(count); | |
cell.setCellValue(d); | |
count = count + 1; | |
</cfscript> | |
</cfloop> | |
</cfloop> | |
<cfscript> | |
fileOutStream = createObject("java", "java.io.FileOutputStream").init(spreadsheetfilename); | |
workBook.write(fileOutStream); | |
fileOutStream.close(); | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment