本文整理汇总了Java中net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter类的典型用法代码示例。如果您正苦于以下问题:Java JRXlsAbstractExporterParameter类的具体用法?Java JRXlsAbstractExporterParameter怎么用?Java JRXlsAbstractExporterParameter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRXlsAbstractExporterParameter类属于net.sf.jasperreports.engine.export包,在下文中一共展示了JRXlsAbstractExporterParameter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setStandardParameters
import net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter; //导入依赖的package包/类
/**
* Configure standard parameters.
* Mainly our aim is to get a clean Excel report.
*/
private final void setStandardParameters()
{
// TODO: use the modern API, but note that we can't mix calls to this deprecated API with calls to the new one.
// Set a password to protect the locked cells.
// NOTE: if no password is set, the cells which are marked as locked won't be locked.
// NOTE2: instead of using a random password, it's better to have a well known one because we are setting the password only to protect the cells from writting and NOT to secure the document.
// setParameter(JRXlsAbstractExporterParameter.PASSWORD, UUID.randomUUID().toString());
setParameter(JRXlsAbstractExporterParameter.PASSWORD, "unlock");
// Take out as much graphics & formatting as possible.
// Our aim is to get a clean Excel file.
setParameter(JRXlsAbstractExporterParameter.IS_IGNORE_GRAPHICS, true);
setParameter(JRXlsAbstractExporterParameter.IS_IGNORE_CELL_BACKGROUND, true);
setParameter(JRXlsAbstractExporterParameter.IS_IGNORE_CELL_BORDER, true);
setParameter(JRXlsAbstractExporterParameter.IS_COLLAPSE_ROW_SPAN, true);
setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, true);
setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, true);
setParameter(JRXlsAbstractExporterParameter.MAXIMUM_ROWS_PER_SHEET, SpreadsheetVersion.EXCEL97.getLastRowIndex());
}
示例2: exportXls
import net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter; //导入依赖的package包/类
/**
* Xls export.
*
* @param jp
* @param os
*/
protected void exportXls(JasperPrint jp, OutputStream os) {
// Create a JRXlsExporter instance
JRXlsExporter exporter = new JRXlsExporter();
// Here we assign the parameters jp and baos to the exporter
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);
// TODO add Excel specific parameters
exporter.setParameter(JRXlsAbstractExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.FALSE);
exporter.setParameter(JRXlsAbstractExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
exporter.setParameter(JRXlsAbstractExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
try {
exporter.exportReport();
} catch (JRException e) {
throw new RuntimeException(e);
}
}
示例3: exportAsExcel
import net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter; //导入依赖的package包/类
private void exportAsExcel(final JasperPrint jasperPrint, final OutputStream out) throws JRException
{
final MetasJRXlsExporter exporter = new MetasJRXlsExporter();
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out); // Output
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint); // Input
// Make sure our cells will be locked by default
// and assume that cells which shall not be locked are particularly specified.
jasperPrint.setProperty(XlsReportConfiguration.PROPERTY_CELL_LOCKED, "true");
// there are cases when we don't want the cells to be blocked by password
// in those cases we put in jrxml the password property with empty value, which will indicate we don't want password
// if there is no such property we take default password. If empty we set no password and if set, we use that password from the report
if(jasperPrint.getProperty(XlsReportConfiguration.PROPERTY_PASSWORD) == null)
{
//do nothing;
}
else if(jasperPrint.getProperty(XlsReportConfiguration.PROPERTY_PASSWORD).isEmpty())
{
exporter.setParameter(JRXlsAbstractExporterParameter.PASSWORD, null);
}
else
{
exporter.setParameter(JRXlsAbstractExporterParameter.PASSWORD, jasperPrint.getProperty(XlsReportConfiguration.PROPERTY_PASSWORD));
}
exporter.exportReport();
}
示例4: store
import net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter; //导入依赖的package包/类
public void store() {
Preferences pref = IReportManager.getPreferences();
pref.putBoolean(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE, jCheckBoxCreateCustomPalette.isSelected() );
pref.put(JExcelApiExporterParameter.PROPERTY_PASSWORD, jTextFieldPassword.getText());
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN, jCheckBoxCollapseRowSpan.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE, jCheckBoxAutoDetectCellType.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED, jCheckBoxFontSizeFixEnabled.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER, jCheckBoxIgnoreCellBorder.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND, jCheckBoxIgnoreCellBackground.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS, jCheckBoxIgnoreGraphics.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED, jCheckBoxImageBorderFixEnabled.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET, jCheckBoxOnePagePerSheet.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, jCheckBoxRemoveEmptySpaceBetweenColumns.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jCheckBoxRemoveEmptySpaceBetweenRows.isSelected() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jCheckBoxWhitePageBackground.isSelected() );
SpinnerNumberModel model = (SpinnerNumberModel)jSpinnerMaximumRowsPerSheet.getModel();
pref.putInt(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET, model.getNumber().intValue());
pref.putBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.useSheetNames", jCheckBoxUseSheetNames.isSelected() );
pref.put(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.sheetNames", jTextArea1.getText().trim());
pref.put(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN, jTextFieldColumn.getText() );
pref.putInt(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW, ((SpinnerNumberModel)jSpinnerFreezeRow.getModel()).getNumber().intValue() );
pref.putBoolean(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED, jCheckBoxFixFontSize.isSelected());
// if (jComboBoxColumnEdge.getSelectedIndex() > 0)
// {
// pref.put(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN_EDGE, (String) ((Tag)jComboBoxColumnEdge.getSelectedItem()).getValue());
// }
// else
// {
// pref.remove(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN_EDGE);
// }
// if (jComboBoxRowEdge.getSelectedIndex() > 0)
// {
// pref.put(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE, (String) ((Tag)jComboBoxRowEdge.getSelectedItem()).getValue());
// System.out.println("Saved " + (String) ((Tag)jComboBoxRowEdge.getSelectedItem()).getValue());
// }
// else
// {
// pref.remove(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE);
// }
}
示例5: configureXlsExporter
import net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter; //导入依赖的package包/类
private void configureXlsExporter(JRExporter exporter, SimpleJasperReportsContext context) {
Preferences pref = IReportManager.getPreferences();
JRPropertiesUtil jrPropUtils = JRPropertiesUtil.getInstance(context);
context.setValue( JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE , pref.getBoolean(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE, jrPropUtils.getBooleanProperty(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE)));
String password = pref.get(JExcelApiExporterParameter.PROPERTY_PASSWORD, jrPropUtils.getProperty(JExcelApiExporterParameter.PROPERTY_PASSWORD));
if (password != null && password.length() > 0)
{
context.setValue( JExcelApiExporterParameter.PROPERTY_PASSWORD ,password);
}
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)));
System.out.println("Setting detect cell type to:" + pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE)));
System.out.println("Setting detect cell type to ("+JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE+"):" + jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND , pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
int maxRowsPerSheet = pref.getInt(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET, jrPropUtils.getIntegerProperty(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET));
if (maxRowsPerSheet > 0)
{
context.setValue( JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET, ""+ maxRowsPerSheet);
}
if (pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.useSheetNames", false))
{
String sheetNames = pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.sheetNames", "");
exporter.setParameter( JRXlsAbstractExporterParameter.SHEET_NAMES, sheetNames.split("\n"));
}
// Add freeze options...
String col = pref.get(JRXlsExporter.PROPERTY_FREEZE_COLUMN, jrPropUtils.getProperty(JRXlsExporter.PROPERTY_FREEZE_COLUMN));
if (col != null && col.length() > 0)
{
context.setValue( JRXlsExporter.PROPERTY_FREEZE_COLUMN, ""+col);
}
// String columnEdge = pref.get(JRXlsExporter.PROPERTY_FREEZE_COLUMN_EDGE, null);
// if (columnEdge != null && columnEdge.length() > 0)
// {
// context.setValue( JRXlsExporter.PROPERTY_FREEZE_COLUMN_EDGE, columnEdge);
// }
// Add freeze options...
int row = pref.getInt(JRXlsExporter.PROPERTY_FREEZE_ROW, jrPropUtils.getIntegerProperty(JRXlsExporter.PROPERTY_FREEZE_ROW,0));
if (row > 0)
{
context.setValue( JRXlsExporter.PROPERTY_FREEZE_ROW, ""+row);
}
// String rowEdge = pref.get( JRXlsExporter.PROPERTY_FREEZE_ROW_EDGE, null);
// if (rowEdge != null && rowEdge.length() > 0)
// {
// context.setValue( JRXlsExporter.PROPERTY_FREEZE_ROW_EDGE, pref.get(JRXlsExporter.PROPERTY_FREEZE_ROW_EDGE, rowEdge));
// }
}
示例6: load
import net.sf.jasperreports.engine.export.JRXlsAbstractExporterParameter; //导入依赖的package包/类
public void load() {
setInit(true);
Preferences pref = IReportManager.getPreferences();
JRPropertiesUtil jrPropUtils = IRLocalJasperReportsContext.getUtilities();
jCheckBoxCreateCustomPalette.setSelected( pref.getBoolean(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE, jrPropUtils.getBooleanProperty(JExcelApiExporterParameter.PROPERTY_CREATE_CUSTOM_PALETTE)));
jTextFieldPassword.setText( pref.get(JExcelApiExporterParameter.PROPERTY_PASSWORD, jrPropUtils.getProperty(JExcelApiExporterParameter.PROPERTY_PASSWORD)));
jCheckBoxCollapseRowSpan.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)));
jCheckBoxAutoDetectCellType.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_DETECT_CELL_TYPE, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)));
jCheckBoxFontSizeFixEnabled.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)));
jCheckBoxIgnoreCellBorder.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BORDER, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_COLLAPSE_ROW_SPAN)));
jCheckBoxIgnoreCellBackground.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_CELL_BACKGROUND)));
jCheckBoxIgnoreGraphics.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IGNORE_GRAPHICS)));
jCheckBoxImageBorderFixEnabled.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_IMAGE_BORDER_FIX_ENABLED)));
jCheckBoxOnePagePerSheet.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_ONE_PAGE_PER_SHEET)));
jCheckBoxRemoveEmptySpaceBetweenColumns.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_COLUMNS)));
jCheckBoxRemoveEmptySpaceBetweenRows.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_REMOVE_EMPTY_SPACE_BETWEEN_ROWS)));
jCheckBoxWhitePageBackground.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_WHITE_PAGE_BACKGROUND)));
SpinnerNumberModel model = (SpinnerNumberModel)jSpinnerMaximumRowsPerSheet.getModel();
model.setValue( pref.getInt(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET, jrPropUtils.getIntegerProperty(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET)));
jCheckBoxUseSheetNames.setSelected( pref.getBoolean(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.useSheetNames", false));
// freeze pane...
String columnIndex = jrPropUtils.getProperty(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN);
if (columnIndex == null) columnIndex = "";
jTextFieldColumn.setText( pref.get(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN, columnIndex));
((SpinnerNumberModel)jSpinnerFreezeRow.getModel()).setValue( pref.getInt(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW, jrPropUtils.getIntegerProperty(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW,0)));
//com.jaspersoft.ireport.designer.utils.Misc.setComboBoxTag(true, pref.get(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN_EDGE, jrPropUtils.getProperty(JRXlsAbstractExporter.PROPERTY_FREEZE_COLUMN_EDGE)), jComboBoxColumnEdge);
//com.jaspersoft.ireport.designer.utils.Misc.setComboBoxTag(true, pref.get(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE, jrPropUtils.getProperty(JRXlsAbstractExporter.PROPERTY_FREEZE_ROW_EDGE)), jComboBoxRowEdge);
jTextArea1.setText(pref.get(JRPropertiesUtil.PROPERTY_PREFIX + "export.xls.sheetNames", jrPropUtils.getProperty(JRXlsAbstractExporterParameter.PROPERTY_MAXIMUM_ROWS_PER_SHEET)));
jCheckBoxFixFontSize.setSelected( pref.getBoolean(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED, jrPropUtils.getBooleanProperty(JRXlsAbstractExporterParameter.PROPERTY_FONT_SIZE_FIX_ENABLED)));
setInit(false);
}