gpt4 book ai didi

java - 如何在eclipse内部编辑器中打开excel文件

转载 作者:太空宇宙 更新时间:2023-11-04 12:37:59 28 4
gpt4 key购买 nike

我需要在 Eclipse 内部编辑器中从项目资源管理器打开 excel 文件。我正在调用下面的函数在编辑器中打开文件。

public static void openFileIntoEditor(String filePath) {
File fileToOpen = new File(filePath);
if (fileToOpen.exists() && fileToOpen.isFile()) {
try {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
IWorkbenchPage page = GUIHandler.getPage();
try {
IDE.openInternalEditorOnFileStore(page, fileStore);
//IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
System.out.println("ERORR in openFileIntoEditor : " + e.getMessage());
}
} catch (Exception e) {
System.out.println("ERORR in openFileIntoEditor2 : " + e.getMessage());
}
} else {
}
}

它适用于文本文件,但当我尝试在内部编辑器中打开 Excel 文件时显示一些二进制代码。我哪里做错了或者我需要做什么才能通过java程序在内部Eclipse编辑器中打开excel文件。

最佳答案

标准 Eclipse 中没有针对 Excel 文件的内部编辑器。因此,您只是使用普通的文本编辑器来尝试编辑二进制文件。

您可以尝试IDE.openEditorOnFileStore,这可能会在 Eclipse 中打开“就地系统编辑器”(您需要在“常规 > 编辑器”页面上的首选项中设置“允许就地系统编辑器”选项)。

关于java - 如何在eclipse内部编辑器中打开excel文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37113062/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com