public Map<String, String> getJasperExportParameters() {
    try {
      String format = getFormat();
      if (JasperReportConstants.FORMAT_XLS.equals(format)) {
        HttpServletRequest request = ServletActionContext.getRequest();
        String reportId = request.getParameter("report");
        File targetJasperFile = getTargetJasperFile(reportId);
        JasperReport jasperReport = (JasperReport) JRLoader.loadObject(targetJasperFile);

        // 为了方便模板设计和生产环境部署,扩展提供一个PROPERTY_WORKBOOK_TEMPLATE_FILENAME参数
        // 如果在模板文件中定义此参数值,框架会用此文件名转换为对应和jasper文件所在同路径的绝对路径去覆盖模板中PROPERTY_WORKBOOK_TEMPLATE参数值
        JRPropertiesMap properties = jasperReport.getPropertiesMap();
        String xlsWorkbookTemplateFilename =
            properties.getProperty(PROPERTY_WORKBOOK_TEMPLATE_FILENAME);
        if (StringUtils.isNotBlank(xlsWorkbookTemplateFilename)) {
          String xlsWorkbookTemplateFilepath =
              getWebRootDir()
                  + getRelativeJasperFilePath()
                  + File.separator
                  + xlsWorkbookTemplateFilename;
          logger.debug(
              "Overwrite jasper property: {}={}",
              JRXlsAbstractExporter.PROPERTY_WORKBOOK_TEMPLATE,
              xlsWorkbookTemplateFilepath);
          exportParameters.put(
              JRXlsAbstractExporter.PROPERTY_WORKBOOK_TEMPLATE, xlsWorkbookTemplateFilepath);
        }
      }
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      throw new WebException(e.getMessage(), e);
    }
    return exportParameters;
  }
 private void fillTable(Table table) {
   List<PropertyDTO> props = new ArrayList<PropertyDTO>();
   String[] names = value.getPropertyNames();
   for (int i = 0; i < names.length; i++) {
     PropertyDTO p = new PropertyDTO();
     p.setProperty(names[i]);
     p.setValue(value.getProperty(names[i]));
     props.add(p);
   }
   tableViewer.setInput(props);
 }
 protected void exportProperties(JRPropertiesHolder propertiesHolder) throws IOException {
   if (propertiesHolder.hasProperties()) {
     JRPropertiesMap propertiesMap = propertiesHolder.getPropertiesMap();
     String[] propertyNames = propertiesMap.getPropertyNames();
     if (propertyNames != null && propertyNames.length > 0) {
       for (int i = 0; i < propertyNames.length; i++) {
         xmlWriter.startElement(JRXmlConstants.ELEMENT_property);
         xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, propertyNames[i]);
         String value = propertiesMap.getProperty(propertyNames[i]);
         if (value != null) {
           xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_value, value);
         }
         xmlWriter.closeElement();
       }
     }
   }
 }
 @Override
 public void dispose() {
   // clear all properties
   value = new JRPropertiesMap();
   List<PropertyDTO> props = (List<PropertyDTO>) tableViewer.getInput();
   for (PropertyDTO p : props) {
     if (p.getProperty() != null && !p.getProperty().equals("")) // $NON-NLS-1$
     value.setProperty(p.getProperty(), p.getValue().toString());
   }
   super.dispose();
 }
  public Object getValue() throws IllegalAccessException, InvocationTargetException {

    JRPropertiesMap map = element.getPropertiesMap();
    List properties = new ArrayList();
    String[] names = map.getPropertyNames();

    for (int i = 0; i < names.length; ++i) {
      properties.add(new GenericProperty(names[i], map.getProperty(names[i])));
    }

    // add to the list the expression properties...
    JRPropertyExpression[] expProperties = element.getPropertyExpressions();
    for (int i = 0; expProperties != null && i < expProperties.length; ++i) {
      properties.add(
          new GenericProperty(
              expProperties[i].getName(),
              (JRDesignExpression) expProperties[i].getValueExpression()));
    }

    return properties;
  }
  public void setValue(Object val)
      throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    // if (!(val instanceof JRPropertiesMap)) throw new IllegalArgumentException();

    if (!(val instanceof List)) throw new IllegalArgumentException();

    // Fill this map with the content of the map we got here...

    // 1. Create the map...
    JRPropertiesMap map = new JRPropertiesMap();
    List values = (List) val;
    for (int i = 0; i < values.size(); ++i) {
      GenericProperty prop = (GenericProperty) values.get(i);
      if (!prop.isUseExpression()) {
        map.setProperty(prop.getKey(), (String) prop.getValue());
      }
    }

    ModelUtils.replacePropertiesMap(map, element.getPropertiesMap());
    ModelUtils.replaceExpressionProperties(element, values);

    com.jaspersoft.ireport.designer.IReportManager.getInstance().notifyReportChange();
  }
  public Object clone() {
    JRBaseParameter clone = null;

    try {
      clone = (JRBaseParameter) super.clone();
    } catch (CloneNotSupportedException e) {
      throw new JRRuntimeException(e);
    }

    clone.defaultValueExpression = JRCloneUtils.nullSafeClone(defaultValueExpression);
    if (propertiesMap != null) {
      clone.propertiesMap = (JRPropertiesMap) propertiesMap.clone();
    }
    clone.eventSupport = null;

    return clone;
  }
  public StandardBaseColumn(BaseColumn column, ColumnFactory factory) {
    this.uuid = column.getUUID();

    this.printWhenExpression =
        factory.getBaseObjectFactory().getExpression(column.getPrintWhenExpression());

    this.tableHeader = factory.createCell(column.getTableHeader());
    this.tableFooter = factory.createCell(column.getTableFooter());
    this.groupHeaders = factory.createGroupCells(column.getGroupHeaders());
    this.groupFooters = factory.createGroupCells(column.getGroupFooters());
    this.columnHeader = factory.createCell(column.getColumnHeader());
    this.columnFooter = factory.createCell(column.getColumnFooter());

    this.width = column.getWidth();

    propertiesMap = JRPropertiesMap.getPropertiesClone(column);
    copyPropertyExpressions(column, factory);
  }
 public synchronized boolean hasProperties() {
   return propertiesMap != null && propertiesMap.hasProperties();
 }
Beispiel #10
0
 public boolean hasProperties() {
   return propertiesMap != null && propertiesMap.hasProperties();
 }