Java 将xls导出为pdf,jexcell不工作

Java 将xls导出为pdf,jexcell不工作,java,excel,pdf,export,itext,Java,Excel,Pdf,Export,Itext,我想打印我用ApachePOI编辑的excel表单。为了保持格式打印,我需要将文件转换为pdf,但是转换在内部总是失败,因为jxcelllibrary 这是我的密码 import com.jxcell.*;<br> import java.io.File;<br> import java.io.FileInputStream;<br> import java.io.FileOutputStream;<br> import java.io.IOExc

我想打印我用ApachePOI编辑的excel表单。为了保持格式打印,我需要将文件转换为pdf,但是转换在内部总是失败,因为
jxcell
library

这是我的密码

import com.jxcell.*;<br>
import java.io.File;<br>
import java.io.FileInputStream;<br>
import java.io.FileOutputStream;<br>
import java.io.IOException;<br>
import javax.swing.JFileChooser;<br>
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;<br>
import org.apache.poi.ss.usermodel.Workbook;<br>
import org.apache.poi.ss.usermodel.WorkbookFactory;<br>

public class PruebaPdf {
 public static void main(String args[]){
      View m_view = new View();
    try
        {   
            File file = new File(GetPath());
            FileInputStream fis = null;
            fis = new FileInputStream(file);
            m_view.read(fis);
            File file2 = new File(SavePath());
            FileOutputStream fis2 = new FileOutputStream(file2);
            m_view.exportPDF(fis2);
    }
    catch (CellException e)
    {
        e.printStackTrace();
    } catch (IOException e)
    {
        e.printStackTrace();
    }
 }
因为它也接受字符串,但不起作用

对于这两种情况,我都得到了这个错误

Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/pdf/FontMapper
    at com.jxcell.View.exportPDF(KKLI)
    at com.jxcell.View.exportPDF(KKLI)
    at PruebaPdf1.main(PruebaPdf.java:[new Int line])
Caused by: java.lang.ClassNotFoundException: com.itextpdf.text.pdf.FontMapper
    at java.net.URLClassLoader$1.run............
line=numberline其中是函数exportPDF


我没有使用
itext
,所以我猜
jxcell
在内部使用它。问题是我不知道解决这个问题的任何方法(除了寻找另一种执行转换的方法)

这个问题的答案,就像所有涉及
NoClassDefFoundError
的问题一样,是下载适当的JAR并将其添加到类路径。谢谢你的回答。iText 5.5.0从我的项目下载并添加到我的项目中。还是有同样的错误。(奇怪的是,它不允许我从itext导入任何内容)好的,我解决了这个问题,至少对我来说是这样。问题是iText的现代版本会给jxcell带来麻烦,所以我将iText降级到5.1.3版本,在那里它开始进行转换。
Exception in thread "main" java.lang.NoClassDefFoundError: com/itextpdf/text/pdf/FontMapper
    at com.jxcell.View.exportPDF(KKLI)
    at com.jxcell.View.exportPDF(KKLI)
    at PruebaPdf1.main(PruebaPdf.java:[new Int line])
Caused by: java.lang.ClassNotFoundException: com.itextpdf.text.pdf.FontMapper
    at java.net.URLClassLoader$1.run............