September 06, 2008
For ColdFusion hosting try HostMySite.com. |
Home /
Groups /
ColdFusion Talk (CF-Talk)
writing to ms excel with jexcel [heur SPAMTRAP]
> kind enough to provide me with a translation of the java instructionsPaul Hastings 05/11/08 10:33 A thanks very much paul, it works perfectly :)Richard White 05/11/08 10:55 A hi paul, thanks again for thisRichard White 05/11/08 11:00 A > therefore how would you translate this formatting stated aboveC S 05/11/08 03:11 P excellent, thanks very much :) works fine!!!Richard White 05/11/08 03:45 P > kind enough to provide me with a translation of the java instructions > into coldfusion please :) <cfscript> outFile = createObject("java", "java.io.File").init("e:\temp\excel\test.xls"); workBook=createObject("java","jxl.Workbook").createWorkbook(outFile); labelObj=createObject("java","jxl.write.Label"); numberObj=createObject("java","jxl.write.Number"); //////////////////////////////////////////////// sheet = workBook.createSheet("First Sheet", 0); thisLabel=labelObj.init(0,0,"happy happy gizmo"); sheet.addCell(thisLabel); thisNumber=numberObj.init(0, 1, 3.1459); sheet.addCell(thisNumber); workbook.write(); workbook.close(); </cfscript> thanks very much paul, it works perfectly :) thanks again richard ----- Excess quoted text cut - see Original Post for more ----- hi paul, thanks again for this just one more thing then i have everything i need :) there are sections in the documentation that allows for number formatting and date formatting such as: WritableCellFormat integerFormat = new WritableCellFormat (NumberFormats.INTEGER); Number number2 = new Number(0, 4, 3.141519, integerFormat); sheet.addCell(number2); WritableCellFormat floatFormat = new WritableCellFormat (NumberFormats.FLOAT); Number number3 = new Number(1, 4, 3.141519, floatFormat); sheet.addCell(number3); NumberFormat fivedps = new NumberFormat("#.#####"); WritableCellFormat fivedpsFormat = new WritableCellFormat(fivedps); Number number4 = new Number(2, 4, 3.141519, fivedpsFormat); sheet.addCell(number4); // Get the current date and time from the Calendar object Date now = Calendar.getInstance().getTime(); DateFormat customDateFormat = new DateFormat ("dd MMM yyyy hh:mm:ss"); WritableCellFormat dateFormat = new WritableCellFormat (customDateFormat); DateTime dateCell = new DateTime(0, 6, now, dateFormat); sheet.addCell(dateCell); and i have noticed that you translated it to: labelObj=createObject("java","jxl.write.Label"); numberObj=createObject("java","jxl.write.Number"); thisLabel=labelObj.init(0,0,"happy happy gizmo"); sheet.addCell(thisLabel); thisNumber=numberObj.init(0, 1, 3.1459); sheet.addCell(thisNumber); therefore how would you translate this formatting stated above thanks very much richard ----- Excess quoted text cut - see Original Post for more ----- > therefore how would you translate this formatting stated above <cfscript> outFile = createObject("java", "java.io.File").init( "e:\temp\excel\test.xls" ); workBook=createObject("java","jxl.Workbook").createWorkbook(outFile); labelObj=createObject("java","jxl.write.Label"); numberObj=createObject("java","jxl.write.Number"); //////////////////////////////////////////////// sheet = workBook.createSheet("First Sheet", 0); thisLabel=labelObj.init(0,0,"happy happy gizmo"); sheet.addCell(thisLabel); thisNumber=numberObj.init(0, 1, 3.1459); sheet.addCell(thisNumber); //////////////////////////////////////////////// NumberFormats = createObject("java", "jxl.write.NumberFormats"); WritableCellFormat = createObject("java", "jxl.write.WritableCellFormat"); Number = createObject("java", "jxl.write.Number"); DateFormat = createObject("java", "jxl.write.DateFormat"); DateTime = createObject("java", "jxl.write.DateTime"); Calendar = createObject("java", "java.util.Calendar"); NumberFormat = createObject("java", "jxl.write.NumberFormat"); integerFormat = WritableCellFormat.init( NumberFormats.INTEGER ); number2 = Number.init( 0, 4, 3.141519, integerFormat ); sheet.addCell( number2 ); floatFormat = WritableCellFormat.init( NumberFormats.FLOAT ); number3 = Number.init( 1, 4, 3.141519, floatFormat ); sheet.addCell( number3 ); // note, # signs are escaped/doubled for CF fivedps = NumberFormat.init("##.##########"); fivedpsFormat = WritableCellFormat.init( fivedps ); number4 = Number.init( 2, 4, 3.141519, fivedpsFormat ); sheet.addCell( number4 ); // Get the current date and time from the Calendar object now = Calendar.getInstance().getTime(); customDateFormat = DateFormat.init( "dd MMM yyyy hh:mm:ss" ); dateFormat = WritableCellFormat.init( customDateFormat ); dateCell = DateTime.init( 0, 6, now, dateFormat ); sheet.addCell( dateCell ); //////////////////////////////////////////////// workbook.write(); workbook.close(); WriteOutput("Done"); </cfscript> excellent, thanks very much :) works fine!!! ----- Excess quoted text cut - see Original Post for more -----
|
Mailing Lists
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||