Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.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 转换为html时需要从ods文件中删除特殊字符_Java_Html_Ods - Fatal编程技术网

Java 转换为html时需要从ods文件中删除特殊字符

Java 转换为html时需要从ods文件中删除特殊字符,java,html,ods,Java,Html,Ods,我正在从事java项目。在本文中,我编写了将ods文件转换为html的代码,然后在浏览器中打开转换后的文件。 下面是我的代码:- private String ConvertOdtAndOdsToHTML(String sDocPath, String finalDestinationPath, String downloadImagePath, String returnPath) { try { String root = finalDestinati

我正在从事java项目。在本文中,我编写了将ods文件转换为html的代码,然后在浏览器中打开转换后的文件。
下面是我的代码:-

private String ConvertOdtAndOdsToHTML(String sDocPath, String finalDestinationPath, String downloadImagePath, String returnPath) {
        try {
            String root = finalDestinationPath;
            int lastIndex = sDocPath.lastIndexOf(File.separator);
            String sFileName = sDocPath.substring(lastIndex + 1, sDocPath.length());
            String fileNameWithOutExt = FilenameUtils.removeExtension(sFileName);
            String fileOutName = root + File.separator + fileNameWithOutExt + ".html";
            InputStream in = new FileInputStream(new File(sDocPath));
            String ext = FilenameUtils.getExtension(sDocPath);
            OdfTextDocument document = null;
            OdfSpreadsheetDocument odfSpreadsheetDocument = null;
            if (ext.equalsIgnoreCase("odt")) {
                 document = OdfTextDocument.loadDocument(in);
            }
            else  if (ext.equalsIgnoreCase("ods")) {
                 odfSpreadsheetDocument = OdfSpreadsheetDocument.loadDocument(in);
            }
            org.odftoolkit.odfdom.converter.xhtml.XHTMLOptions options = org.odftoolkit.odfdom.converter.xhtml.XHTMLOptions.create();
            // Extract image
            String sLocalSystemImagePath = finalDestinationPath + File.separator+"images"+File.separator;
            File imageFolder = new File(sLocalSystemImagePath);


            options.setExtractor( new org.openskye.resource.FileImageExtractor( imageFolder ) );
            // URI resolver
            String localHostImagePath = downloadImagePath + File.separator+"images"+File.separator;
            FileResolverOdt fileURIResolver = new FileResolverOdt(new File(localHostImagePath));
            options.URIResolver(fileURIResolver);
            // URI resolver

            OutputStream out = new FileOutputStream(new File(fileOutName));
            if (ext.equalsIgnoreCase("odt")) {
                org.odftoolkit.odfdom.converter.xhtml.XHTMLConverter.getInstance().convert(document, out, options);
            }
            else if (ext.equalsIgnoreCase("ods")) {
                org.odftoolkit.odfdom.converter.xhtml.XHTMLConverter.getInstance().convert(odfSpreadsheetDocument, out, options);
            }
            return returnPath + File.separator + fileNameWithOutExt + ".html";
        } catch (Exception e) {
            return "Failed to open the document: " + sDocPath + " due to error:" + e.getMessage();
        }
    }
我能够将ods文件转换为html,文件也在浏览器中打开,但它显示了一些问号????以及浏览器中的日期和时间。 我只想在open office中打开文件时显示它,而不显示日期时间和任何特殊字符。我还想区分这些表

这是我要转换的ods文件 下面是转换为html的ods文件的附加屏幕截图


如果有人能帮我找到解决方案,我将不胜感激。

你能展示一个ODS输入文件和一个HTML输出(实际的标记,而不是网页)样本吗?@dbank请查看上面编辑的ODS和HTML文件帖子