Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Source code |
|
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
Option Explicit ' ' Demo for Excel access via JExcel ' ' Migrated from Java to Jabaco from ' http://www.tutorials.de/forum/java/267257-kleines-beispiel-zur-jexcel-api.html ' ' JExcel: http://jexcelapi.sourceforge.net/ ' ' Download JExcel distribution from URL above and add jxl.jar to ' Jabaco classpath (press F1) ' import java.io.File; ' import java.util.Date; ' import jxl.Workbook; ' import jxl.write.DateFormats; ' import jxl.write.DateTime; ' import jxl.write.Label; ' import jxl.write.Number; ' import jxl.write.NumberFormats; ' import jxl.write.WritableCellFormat; ' import jxl.write.WritableSheet; ' import jxl.write.WritableWorkbook; Public Sub ExcelDemo Dim workbook As jxl#write#WritableWorkbook Dim testSheet As jxl#write#WritableSheet Dim file As java#io#File Dim numberFormat As jxl#write#WritableCellFormat Dim dateFormat As jxl#write#WritableCellFormat Dim number As jxl#write#Number Dim dateCell As jxl#write#DateTime Dim fileName As String Dim currentColumn As Integer = 0 Dim currentRow As Integer = 0 fileName = system.getenv("TEMP") & "\text-jexcel1.xls" file = New java#io#File(fileName) workbook = jxl#Workbook.createWorkbook(file) testSheet = workbook.createSheet("test", 0) numberFormat = New jxl#write#WritableCellFormat(jxl#write#NumberFormats.FLOAT) number = New jxl#write#Number(currentColumn, currentRow, 12345.0, numberFormat) currentColumn = currentColumn + 1 testSheet.addCell(number) testSheet.addCell(New jxl#write#Label(currentColumn, currentRow, "TEST")) currentColumn = currentColumn + 1 dateFormat = New WritableCellFormat(jxl#write#DateFormats.DEFAULT) ' the following line leads to a Jabaco compile error dateCell = New jxl#write#DateTime(currentColumn, currentRow, New java#util#Date(), dateFormat) currentColumn = currentColumn + 1 testSheet.addCell(dateCell) workbook.write workbook.close End Sub |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
This post has been edited 2 times, last edit by "A1880" (Feb 3rd 2009, 9:01pm)
Quoted
unfortunately, the resulting Excel file does not get a correct DateCell written
Jabaco Source |
|
1 2 3 |
Dim myDate As Date myDate = "03.02.2009" dateCell = New jxl#write#DateTime(currentColumn, currentRow, myDate, dateFormat) |
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Source code |
|
1 2 3 |
myDate = Conversion.CDate("03.02.2009"); dateCell = new DateTime(currentColumn, currentRow, myDate, (CellFormat)dateFormat); |
This post has been edited 1 times, last edit by "joda" (Oct 2nd 2010, 7:00pm)
Intermediate
Date of registration: Jan 1st 2009
Location: Hanover, Germany
Occupation: Software Engineer
Hobbies: Hilbert Curves
Jabaco Source |
|
1 2 |
' Download JExcel distribution from URL above and add jxl.jar to
' Jabaco classpath (press F1)
|