Technical notes
Internationalization and Unicode
ExcelRead supports the full unicode character set for internationalization. However there can be issues when displaying these - the default behaviour when writing out a unicode String to a stream is to encode the string using UTF-8 encoding. For genuine unicode characters this results in a loss of information.Accounting Date Formats
As of version 1.4 the excel cell formatting is preserved. However if the numerical cell format is an accounting format which incorporates a currency sign (such as sterling or yen) then this is not represented within the standard ASCII character set. The currency symbol will be included as part of the Unicode character set, so the necessary steps should be taken to output the result of getContents() in a unicode aware environment. For the CSV demo program, this simply involves invoking it with the -unicode switch on the command line.Memory Allocation and Sheet Caching
For very large files, it was found that reading in the entire workbook led to horrendous performance. As of version 1.6, it was therefore decided to read in a sheet at a time. Every call to getSheet() frees up all the objects currently allocated in the current sheet and then reads in all the data from the next sheet. This alleviated the problems which previously occurred, but it does however assume that the giant size workbooks are spread over several sheets - if not, performance problems and OutOfMemoryExceptions may still occur.Date Format and Fractions of a Second
If a date format is specified in Excel eg. as mm:ss.00 ie. in order to display hundredths of a second, then the corresponding java data format is mm:ss.SS. On Unix/Linux systems this renders the hundredths of a second as expected. Unfortunately on Windows/NT systems the format is unpredictable. In order to get around this, any fractional representation in Excel defaults to mm:ss.SSS in order for the correct display on NT systems. Thus a time of 01:10.05 will be displayed as 01:10.050.Writing Dates to Excel
When using dates (from the util package), Java will automatically perform any timezone adjustments for you. Thus if you create a date using the Calendar object in the EST, Java will store this in the GMT equivalent (ie. EST + 5hrs) and also store the offset ie. -5hrs. When java.util.Dates are passed to the JExcelApi, these have to be converted into an Excel date value before it can be stored. The way this is handled is that it obtains the GMT value from the date, and then obtains the timezone offset FOR THE DEFAULT TIMEZONE; thus in the earlier example it will obtain GMT, take the EST offset, add it on, and convert this to an Excel date value. Normally this behaviour is sufficient, and the client application is unaware that timezone information has been incorporated.TimeZone gmtZone = TimeZone.getTimeZone("GMT");
SimpleDateFormat format = new SimpleDateFormat("dd MMM yyyy");
format.setTimeZone(gmtZone);
DateCell dateCell = ....
String dateString = format.format(dateCell.getDate());
Writing Dates to Excel
As of JExcelApi v2.3 writing of formulas is supported. However, please note that when passing in the formula to be written, JExcelApi only attempts to generate the Excel tokens - it only does the most rudimentary syntactic checking of the formula. This means that if an application passes an erroneous formula string, the results when Excel attempts to open the generated file are undefined.Alternative methods of logging
The philosophy of JExcelApi has always been "download and go", hence JExcelApi has no dependencies on any third party libraries. This means that when it came to logging, JExcelApi has simply written messages to stdout and stderr. However, for more complex applications this simple behaviour may prove a little too rudimentary, so from version 2.4 it is possible (with a little technical know-how) to plug in more sophisticated logging mechanism. In order to preserve the principle of no dependencies, the JExcelApi distribution is built in stand-alone mode by default (with the simple logging mechanism) - to use an alternative means of logging requires changing a config file and rebuildingHyperlinks
Very long URLs do not appear to work when added as a HYPERLINK formula - this can be verified by typing something like the following into Excel itself=HYPERLINK("http://www.verylongurl.com/.....", "label")When the label is clicked, for long URLs Excel reports that it is unable to contact the server. The reason for this is that the URL value exceeds Excel's internal limit for parsing formulas
WritableSheet.addHyperlink(...)can be used instead
Specifying and Disabling features
JExcelApi supports a number of features by default (such as images, macros, formulas etc). If, for any reason you wish to turn these off, for example, in order to improve performance or to avoid a bug, the JExcelApi has two ways of doing this.java -Djxl.nowarnings=true -jar jxl.jar -rw mysheet.xls copy.xlsThe other way is to set the appropriate property on the WorkbookSettings bean that you use to create the workbook, as follows:
File myfile = new File("...");This is the list of features which may be disabled, the system property name and the corresponding method on the WorkbookSettings bean
WorkbookSettings settings = new WorkbookSettings();
settings.setSuppressWarnings(true);
Workbook workbook = Workbook.getWorkbook(myfile, settings);
| Feature | System Property | Workbook Settings Bean Method |
| Don't display warnings during execution | jxl.nowarnings | setSuppressWarnings(boolean) |
| Ignore all chart and image information | jxl.nodrawings | setDrawingsDisabled(boolean) |
| Ignore named cells and ranges | jxl.nonames | setNamesDisabled(boolean) |
| Ignore blank cells (this stops the instantiation of Blank cell objects, which can cause quite a lot of memory usage in very large spreadsheets) | jxl.noblanks | setIgnoreBlankCells(boolean) |
| Ignore any cell validations | jxl.nocellvalidation | setCellValidationDisabled(boolean) |
| Disable automatic garbage collection hints | jxl.nogc | setGCDisabled(boolean) |
| Disable cell format rationalization (ie. potentially allow duplicate cell formats within a workbook) | jxl.norat | setRationalization(boolean) |
| Disable adjusting of formula references when rows/columns are either inserted or deleted | jxl.noformulaadjust | setFormulaAdjust(boolean) |
| Disable reading of additional property sets - this will have the effect of not copying macros or other VB components of a workbook | jxl.nopropertysets | setPropertySets(boolean) |
| The encoding to use for reading non unicode strings | file.encoding | setEncoding(String) |
| Don't check for overlapping merged cells or ranges during the write phase | jxl.nomergedcellchecks | setMergedCellChecking(boolean) |
| Two letter locale language identifier | jxl.lang | setEncoding(String) |
| Two letter locale country identifier | jxl.country | setEncoding(String) |
| The directory where any temporary files will be writting | jxl.temporaryfileduringwritedirectory | setTemporaryFileDuringWriteDirectory(File)) |
| Use a temporary file to write out the final file, rather than generate the whole thing in memory | jxl.usetemporaryfileduringwrite | setTemporaryFileDuringWrite(boolean) |