如何使用Java在内存中创建Excel文件而不写入磁盘并使用R读取它

时间:2018-08-14 16:42:48

标签: java r excel

就像标题所述,我目前需要在java中创建一个excel文件,然后使用R读取它。以前,该过程是使用Apache POI创建excel并将其写入磁盘,然后使用R从磁盘读取该文件。

我想知道是否有一种方法可以在内存中创建出色的Excel(就像存在虚拟文件系统一样),并要求R从那里读取。

谢谢

1 个答案:

答案 0 :(得分:0)

您可以创建RAM drive(例如,ImDisk for Window,或者如果使用其他操作系统,请参见List of RAM drive software)。然后使用public class Processor { private Map<Class<? extends ObjTypeAbstract>, ProcessorInterface<? extends ObjTypeAbstract >> map = new HashMap<>(); public Processor(){ map.put(ObjType.class, new ObjProcessor()); map.put(ScriptType.class, new ScriptProcessor()); } public void methodAbc(ObjTypeAbstract obj) { @SuppressWarnings("unchecked") ProcessorInterface<ObjTypeAbstract> processorInterface = (ProcessorInterface<ObjTypeAbstract>) map.get(obj.getClass()); processorInterface.abcMethod(obj); } } 将excel文件写入RAM驱动器,并使用-- Case using 1 output column 'COUNT(*)', 1 filter variable 'eb_key' DECLARE -- eb_key VARCHAR2(100) := 'something'; l_entry_found number; -- BEGIN execute immediate 'SELECT COUNT(*) FROM hera.hera_user@iam WHERE username = :eb_key;' USING eb_key INTO l_entry_found; END; -- Case using 2 output column 'COUNT(*)', 3 filter variable 'eb_key' DECLARE -- eb_column1 VARCHAR2(100) := 'something'; eb_column2 VARCHAR2(100) := 'something'; l_entry_found1 number; l_entry_found2 number; -- BEGIN execute immediate 'SELECT column1, column2 FROM hera.hera_user@iam WHERE username = :eb_1 AND lastname = :eb_2;' USING eb_column1, eb_column2 INTO l_entry_found1,l_entry_found2; END; 等与excel相关的软件包从RAM驱动器中读取R。