House of Fusion
Home of the ColdFusion Community
Hostmysite VPS Hosting

Search cf-talk

September 06, 2008

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
   1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30         

Subscribe Now
Fusion Authority Quarterly Update - ColdFusion 8 Special Edition

For ColdFusion hosting try HostMySite.com.
Search over 2,500 ColdFusion resources here  >>>      
Home /  Groups /  ColdFusion Talk (CF-Talk)

writing to ms excel with jexcel [heur SPAMTRAP]

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Paul Hastings
05/11/2008 10:33 AM

> 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>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
05/11/2008 10:55 AM

thanks very much paul, it works perfectly :) thanks again richard ----- Excess quoted text cut - see Original Post for more -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
05/11/2008 11:00 AM

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 -----

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
C S
05/11/2008 03:11 PM

> 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>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Richard White
05/11/2008 03:45 PM

excellent, thanks very much :) works fine!!! ----- Excess quoted text cut - see Original Post for more -----


<< Previous Thread Today's Threads Next Thread >>

Mailing Lists