-
Notifications
You must be signed in to change notification settings - Fork 6
如何生成Excel文件范例
张弓 edited this page Feb 19, 2021
·
1 revision
如何生成Excel文件范例:
ExportFile export = new ExportFile(app.getService(), app.getExportKey());
bottom.addMenu("导出(Excel)", String.format("FrmSample.exportExcel?service=%s&exportKey=%s",
export.getService(), export.getKey()));
public IPage exportExcel() throws WriteException, IOException, AccreditException {
ExportExcel export = new ExportExcel(getResponse());
export.setHandle(this);
export.setTemplateId("FrmSample");
String service = getRequest().getParameter("service");
String exportKey = getRequest().getParameter("exportKey");
LocalService app = new LocalService(this);
app.setService(service);
try (MemoryBuffer buff = new MemoryBuffer(BufferType.getExportKey, this.getUserCode(), exportKey)) {
app.getDataIn().close();
app.getDataIn().setJSON(buff.getString("data"));
}
if (app.exec()) {
export.getTemplate().setDataSet(app.getDataOut());
export.export();
} else
export.export(app.getMessage());
return null;
}
<bean id="FrmSample" class="cn.cerc.jexport.excel.Template"
scope="prototype">
<property name="fileName" value="Excel导出范例" />
<property name="columns">
<list>
<bean class="cn.cerc.jexport.excel.StringColumn">
<property name="code" value="Code_" />
<property name="name" value="代码" />
</bean>
<bean class="cn.cerc.jexport.excel.StringColumn">
<property name="code" value="Name_" />
<property name="name" value="名称" />
</bean>
</list>
</property>
</bean>
summer-footer
summer-db