==================================================================== */
package org.apache.poi.hssf.eventusermodel;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Date;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.usermodel.HSSFDataFormat;
import org.apache.poi.hssf.usermodel.HSSFDataFormatter;
-import org.apache.poi.hssf.usermodel.HSSFDateUtil;
/**
* A proxy HSSFListener that keeps track of the document
this.childListener = childListener;
}
+ protected int getNumberOfCustomFormats() {
+ return customFormatRecords.size();
+ }
+ protected int getNumberOfExtendedFormats() {
+ return xfRecords.size();
+ }
+
/**
* Process this record ourselves, and then
* pass it on to our child listener
/**
* Ensure that all number and formula records can be
- * turned into strings without problems
+ * turned into strings without problems.
+ * For now, we're just looking to get text back, no
+ * exceptions thrown, but in future we might also
+ * want to check the exact strings!
*/
public void testTurnToString() throws Exception {
- processFile("45365.xls");
-
- for(int i=0; i<mockListen._records.size(); i++) {
- Record r = (Record)mockListen._records.get(i);
- CellValueRecordInterface cvr = null;
+ String[] files = new String[] {
+ "45365.xls", "45365-2.xls", "MissingBits.xls"
+ };
+ for(int k=0; k<files.length; k++) {
+ processFile(files[k]);
- if(r instanceof NumberRecord) {
- cvr = (CellValueRecordInterface)r;
- }
- if(r instanceof FormulaRecord) {
- cvr = (CellValueRecordInterface)r;
- }
+ // Check we found our formats
+ assertTrue(listener.getNumberOfCustomFormats() > 5);
+ assertTrue(listener.getNumberOfExtendedFormats() > 5);
- if(cvr != null) {
- // Should always give us a string
- String s = listener.formatNumberDateCell(cvr);
- assertNotNull(s);
- assertTrue(s.length() > 0);
+ // Now check we can turn all the numeric
+ // cells into strings without error
+ for(int i=0; i<mockListen._records.size(); i++) {
+ Record r = (Record)mockListen._records.get(i);
+ CellValueRecordInterface cvr = null;
+
+ if(r instanceof NumberRecord) {
+ cvr = (CellValueRecordInterface)r;
+ }
+ if(r instanceof FormulaRecord) {
+ cvr = (CellValueRecordInterface)r;
+ }
+
+ if(cvr != null) {
+ // Should always give us a string
+ String s = listener.formatNumberDateCell(cvr);
+ assertNotNull(s);
+ assertTrue(s.length() > 0);
+ }
}
+
+ // TODO - test some specific format strings
}
-
- // TODO - test some specific format strings
}
private static final class MockHSSFListener implements HSSFListener {