Fix Open Office Spreadsheet (ODS) dates (#2843)
* Truncate any completely empty columns on the right Fixes #565 The current versions of Open Office create default spreadsheets with over 1000 empty columns. Keep track of the rightmost non-empty column when importing and truncate everything else. Also adds a basic ODS import test. * Fix dates in ODS spreadsheets Fixes #2224
This commit is contained in:
parent
952447461f
commit
3717111db8
@ -39,6 +39,7 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -216,7 +217,7 @@ public class OdsImporter extends TabularImportingParserBase {
|
||||
} else if ("float".equals(cellType)) {
|
||||
value = cell.getDoubleValue();
|
||||
} else if ("date".equals(cellType)) {
|
||||
value = cell.getDateValue();
|
||||
value = cell.getDateValue().toInstant().atOffset(ZoneOffset.UTC);
|
||||
} else if ("currency".equals(cellType)) {
|
||||
value = cell.getCurrencyValue();
|
||||
} else if ("percentage".equals(cellType)) {
|
||||
|
@ -43,6 +43,7 @@ import static org.testng.Assert.assertTrue;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.OffsetDateTime;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.testng.Assert;
|
||||
@ -109,8 +110,7 @@ public class OdsImporterTests extends ImporterTest {
|
||||
Row row = project.rows.get(0);
|
||||
assertEquals(row.cells.size(), COLUMNS);
|
||||
assertEquals((String)row.getCellValue(1),"2 Days In New York");
|
||||
// FIXME: Dates are currently broken
|
||||
// assertEquals(((OffsetDateTime)row.getCellValue(3)).toString().substring(0, 10),"2012-03-28");
|
||||
assertEquals(((OffsetDateTime)row.getCellValue(3)).toString().substring(0, 10),"2012-03-28");
|
||||
assertEquals(((Number)row.getCellValue(5)).doubleValue(), 4.5, EPSILON);
|
||||
|
||||
assertFalse((Boolean)row.getCellValue(7));
|
||||
|
BIN
main/tests/server/src/com/google/refine/importers/films.ods
Normal file
BIN
main/tests/server/src/com/google/refine/importers/films.ods
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user