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 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); } }
@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); }
final XlsFileConfig xlsFileConfig = (XlsFileConfig) XlsFileConfig.getForFile(fileConfig); final ExcelFormatPluginConfig excelFormatPluginConfig = new ExcelFormatPluginConfig(); excelFormatPluginConfig.sheet = xlsFileConfig.getSheetName(); excelFormatPluginConfig.extractHeader = xlsFileConfig.getExtractHeader(); excelFormatPluginConfig.hasMergedCells = xlsFileConfig.getHasMergedCells(); excelFormatPluginConfig.xls = true; return excelFormatPluginConfig;
final XlsFileConfig xlsFileConfig = (XlsFileConfig) this; stringBuilder.append("type => 'excel', "); if (xlsFileConfig.getSheetName() != null) { stringBuilder.append(format("sheet => %s, ", SqlUtils.stringLiteral(xlsFileConfig.getSheetName()))); stringBuilder.append(format("extractHeader => %s, ", xlsFileConfig.getExtractHeader().toString())); stringBuilder.append(format("hasMergedCells => %s, ", xlsFileConfig.getHasMergedCells().toString())); stringBuilder.append(format("xls => true ")); return stringBuilder.toString();
@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); }
public XlsFileConfig newMessage() { return new XlsFileConfig(); }
((ExcelFileConfig) file2Format).setExtractHeader(true); } else { ((XlsFileConfig) file2Format).setExtractHeader(true);
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; }
final ExcelFormatPluginConfig excelFormatPluginConfig = (ExcelFormatPluginConfig)formatPlugin.getConfig(); if (excelFormatPluginConfig.xls) { final XlsFileConfig xlsFileConfig = new XlsFileConfig(); xlsFileConfig.setExtractHeader(excelFormatPluginConfig.extractHeader); xlsFileConfig.setHasMergedCells(excelFormatPluginConfig.hasMergedCells); xlsFileConfig.setSheetName(excelFormatPluginConfig.sheet); return xlsFileConfig; } else {