Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/29.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Apache元模型DataContext.getDefaultSchema不工作_Java_Excel_Apache Metamodel - Fatal编程技术网

Java Apache元模型DataContext.getDefaultSchema不工作

Java Apache元模型DataContext.getDefaultSchema不工作,java,excel,apache-metamodel,Java,Excel,Apache Metamodel,我目前正在使用Apache的Metamodel4.6.0API for Java1.8。获取要使用的DataContext的默认架构时遇到问题。下面是我的代码片段: private DataContext dataContext; private Schema schema; private Table table; /** * @brief Constructor that takes in an excel file * @detail Creates a schema for the

我目前正在使用Apache的Metamodel4.6.0API for Java1.8。获取要使用的DataContext的默认架构时遇到问题。下面是我的代码片段:

private DataContext dataContext;
private Schema schema;
private Table table;

/**
 * @brief Constructor that takes in an excel file
 * @detail Creates a schema for the excel file to be easily queried
 * @param excelFile 
 */
public ExcelQuery(File file)
{
    dataContext = new ExcelDataContext(file);
    schema = dataContext.getDefaultSchema();
    table = schema.getTables()[0];
}
当谈到这一部分时:

schema = dataContext.getDefaultSchema();
代码在尝试执行此操作时挂起。你知道为什么会这样吗


我的目标是能够使用此API查询excel文件。我已经看到许多示例可以这样做,但似乎无法重新创建它。

正如您所说的DataContext.getDefaultSchema不起作用,请尝试使用

Schema[] schema = dc.getSchemas();
然后尝试正确的schemaName

Schema schema = dc.getSchemaByName(schemaName);

你用多个Excel文件测试过吗?他们都被吊死了还是只是其中的一部分?