Package org.zkoss.zss.model

Examples of org.zkoss.zss.model.Importer


    if (_book == null) {
      if (_src == null) {
        throw new UiException("Must specify the src of the spreadsheet to create a new book");
      }
      try {
        Importer importer = _importer;
        if(importer == null){
          importer = new ExcelImporter();
        }

        if(importer instanceof ExcelImporter){
          URL url = null;
         
          if(_src.startsWith("/")){//try to load by application context.
            File file = new File(Executions.getCurrent().getDesktop().getWebApp().getRealPath(_src));
            if(file.exists()){
              url = file.toURI().toURL();
            }
          }
          if(url==null){//try to load from class loader
            url = new ClassLocator().getResource(_src);
          }
          if(url==null){//try to load from file
            File f = new File(_src);
            if(f.exists()){
              url = f.toURI().toURL();
            }
          }
         
          if(url==null){
            throw new UiException("resource for "+_src+" not found.");
          }

          _book = ((ExcelImporter)importer).imports(url);
        }else{
          _book = importer.imports(_src);
        }
       
        _book.addSSDataListener(_dataListener);
        _book.addVariableResolver(_variableResolver);
        _book.addFunctionMapper(_functionMapper);
View Full Code Here


    if (_book == null) {
      if (_src == null) {
        return null;
      }
      try {
        Importer importer = _importer;
        if (importer == null) {
          importer = new ExcelImporter();
        }

        Book book = null;
        if (importer instanceof ExcelImporter) {
          URL url = null;
         
          if (_src.startsWith("/")) {// try to load by application
            // context.
            WebApp wapp = Executions.getCurrent().getDesktop().getWebApp();
            String path = wapp.getRealPath(_src);
            if (path != null) {
              File file = new File(path);
//              if (file.isDirectory())
//                throw new IllegalArgumentException("Your input source is a directory, not a vaild file");
              if (file.exists())
                url = file.toURI().toURL();
            } else
              url = wapp.getResource(_src);
          }
          if (url == null) {// try to load from class loader
            url = new ClassLocator().getResource(_src);
          }
          if (url == null) {// try to load from file
            File f = new File(_src);
            if (f.exists()) {
              url = f.toURI().toURL();
            }
          }

          if (url == null) {
            throw new UiException("resource for " + _src + " not found.");
          }

          book = ((ExcelImporter) importer).importsFromURL(url);
        } else {
          book = importer.imports(_src);
        }

        initBook(book); //will set _book inside this method
      } catch (Exception ex) {
        throw UiException.Aide.wrap(ex);
View Full Code Here

  Spreadsheet spreadsheet;
  Button invalidateSpreadsheetBtn;
  Button setChartBook;
 
  public void onClick$setChartBook() {
    Importer importer = Importers.getImporter("excel");
    final InputStream is = Sessions.getCurrent().getWebApp().getResourceAsStream("/xls/graficas.xlsx");
    Book book = importer.imports(is, "graficas.xlsx");
    spreadsheet.setBook(book);   
  }
View Full Code Here

TOP

Related Classes of org.zkoss.zss.model.Importer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.