public XlsFileConfig newMessage() { return new XlsFileConfig(); }
public static FileFormat getEmptyConfig(FileType type) { switch (type) { case TEXT: case CSV: case TSV: case PSV: return new TextFileConfig(); case JSON: return new JsonFileConfig(); case PARQUET: return new ParquetFileConfig(); case AVRO: return new AvroFileConfig(); case HTTP_LOG: return new HttpLogFileConfig(); case EXCEL: return new ExcelFileConfig(); case XLS: return new XlsFileConfig(); case UNKNOWN: break; default: break; } return null; }
private Invocation getXlsTestQueryInvocation(String filePath, String sheet, boolean extractHeader, boolean hasMergedCells) throws Exception { XlsFileConfig fileConfig = new XlsFileConfig(); fileConfig.setSheetName(sheet); if (extractHeader) { fileConfig.setExtractHeader(true); } // false is the default value if (hasMergedCells) { fileConfig.setHasMergedCells(true); } // false is the default value return getBuilder(getAPIv2().path("/source/dacfs_test/file_preview" + filePath)) .buildPost(Entity.json(fileConfig)); }
@Test public void testDefaultXlsFileFormatOptions() throws Exception { XlsFileConfig fileFormat = new XlsFileConfig(); String tableOptions = fileFormat.toTableOptions(); assertContains("type => 'excel'", tableOptions); assertContains("extractHeader => false", tableOptions); assertContains("hasMergedCells => false", tableOptions); assertContains("xls => true", tableOptions); }
@Test public void testExtractHeaderXlsFile() throws Exception { XlsFileConfig fileFormat = new XlsFileConfig(); fileFormat.setExtractHeader(true); String tableOptions = fileFormat.toTableOptions(); assertContains("type => 'excel'", tableOptions); assertContains("xls => true", tableOptions); assertContains("extractHeader => true", tableOptions); }
@Test public void testSheetXlsFile() throws Exception { XlsFileConfig fileFormat = new XlsFileConfig(); fileFormat.setSheetName("foo"); String tableOptions = fileFormat.toTableOptions(); assertContains("type => 'excel'", tableOptions); assertContains("xls => true", tableOptions); assertContains("sheet => 'foo'", tableOptions); }
@Test public void testHasMergedCellsXlsFile() throws Exception { XlsFileConfig fileFormat = new XlsFileConfig(); fileFormat.setHasMergedCells(true); String tableOptions = fileFormat.toTableOptions(); assertContains("type => 'excel'", tableOptions); assertContains("xls => true", tableOptions); assertContains("hasMergedCells => true", tableOptions); } }
final ExcelFormatPluginConfig excelFormatPluginConfig = (ExcelFormatPluginConfig)formatPlugin.getConfig(); if (excelFormatPluginConfig.xls) { final XlsFileConfig xlsFileConfig = new XlsFileConfig(); xlsFileConfig.setExtractHeader(excelFormatPluginConfig.extractHeader); xlsFileConfig.setHasMergedCells(excelFormatPluginConfig.hasMergedCells);