Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.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
Coding style “线程中的异常”;“主要”;java.lang.IllegalArgumentException:找不到StyleMasterPage名称_Coding Style - Fatal编程技术网

Coding style “线程中的异常”;“主要”;java.lang.IllegalArgumentException:找不到StyleMasterPage名称

Coding style “线程中的异常”;“主要”;java.lang.IllegalArgumentException:找不到StyleMasterPage名称,coding-style,Coding Style,我正在开发一个处理ODS格式文件的应用程序。代码片段如下: public static void main(String[] args) throws IOException { // Set the platform L&F. try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.p

我正在开发一个处理ODS格式文件的应用程序。代码片段如下:

public static void main(String[] args) throws IOException {

    // Set the platform L&F.
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        e.printStackTrace();
    }

    display();
    //print();
}

private static void display() throws IOException {
    // Load the spreadsheet.
    final OpenDocument doc = new OpenDocument();

    doc.loadFrom("temperature3.ods");
    String styleName = "Calibri";
    StyleHeader header = new StyleHeader();
    header.setStyleDisplay("Testing");
    StyleMasterPage page = new StyleMasterPage();
    page.setStyleHeader(header);
    page.setStyleName(styleName);
    OfficeMasterStyles off = new OfficeMasterStyles();
    off.addMasterPage(off.getMasterPageFromStyleName(styleName));

        doc.setMasterStyles(off);

    // Show time !
    final JFrame mainFrame = new JFrame("Viewer");
    DefaultDocumentPrinter printer = new DefaultDocumentPrinter();

    ODSViewerPanel viewerPanel = new ODSViewerPanel(doc, true);

    mainFrame.setContentPane(viewerPanel);
    mainFrame.pack();
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    mainFrame.setLocation(10, 10);
    mainFrame.setVisible(true);

}
为了便于操作,我打算将文件加载到jcomponent中,但在netbeans控制台中出现以下错误消息:

Exception in thread "main" java.lang.IllegalArgumentException: Unable to find StyleMasterPage named:Calibri
at org.jopendocument.model.office.OfficeMasterStyles.getMasterPageFromStyleName(Unknown Source)
    at starzsmarine1.PrintSpreadSheet.display(PrintSpreadSheet.java:60)
    at starzsmarine1.PrintSpreadSheet.main(PrintSpreadSheet.java:45)
是否有用于此目的的替代API