pioneer
2 years ago
commit
5095731df1
9 changed files with 207 additions and 0 deletions
@ -0,0 +1,6 @@
|
||||
# open-JSD-10084 |
||||
|
||||
JSD-10084 多sheet 导出指定sheet页\ |
||||
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\ |
||||
仅作为开发者学习参考使用!禁止用于任何商业用途!\ |
||||
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系【pioneer】处理。 |
Binary file not shown.
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<plugin> |
||||
<id>com.fr.plugin.hd.pdf</id> |
||||
<name><![CDATA[导出Pdf文件定制]]></name> |
||||
<active>yes</active> |
||||
<version>1.1</version> |
||||
<env-version>10.0</env-version> |
||||
<jartime>2018-07-31</jartime> |
||||
<vendor>fr.open</vendor> |
||||
<description><![CDATA[导出Pdf文件定制]]></description> |
||||
<change-notes><![CDATA[ |
||||
<p>导出Pdf文件定制</p> |
||||
]]></change-notes> |
||||
<main-package>com.fr.plugin.hd</main-package> |
||||
<prefer-packages> |
||||
<prefer-package>com.fanruan.api</prefer-package> |
||||
</prefer-packages> |
||||
<extra-core> |
||||
<LocaleFinder class="com.fr.plugin.hd.LocaleFinder"/> |
||||
<PDFExporterCreator class="com.fr.plugin.hd.provider.CustomPDFExporterCreator"/> |
||||
</extra-core> |
||||
<function-recorder class="com.fr.plugin.hd.LocaleFinder"/> |
||||
</plugin> |
@ -0,0 +1,40 @@
|
||||
/* |
||||
* Copyright (C), 2018-2020 |
||||
* Project: starter |
||||
* FileName: LocaleFinder |
||||
* Author: xx |
||||
* Date: 2020/8/31 22:19 |
||||
*/ |
||||
package com.fr.plugin.hd; |
||||
|
||||
import com.fr.intelli.record.Focus; |
||||
import com.fr.intelli.record.Original; |
||||
import com.fr.record.analyzer.EnableMetrics; |
||||
import com.fr.stable.fun.Authorize; |
||||
import com.fr.stable.fun.impl.AbstractLocaleFinder; |
||||
|
||||
import static com.fr.plugin.hd.LocaleFinder.PLUGIN_ID; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <LocaleFinder> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
@EnableMetrics |
||||
@Authorize(callSignKey = PLUGIN_ID) |
||||
public class LocaleFinder extends AbstractLocaleFinder { |
||||
public static final String PLUGIN_ID = "com.fr.plugin.hd.pdf"; |
||||
|
||||
@Override |
||||
@Focus(id = PLUGIN_ID, text = "Plugin-hd", source = Original.PLUGIN) |
||||
public String find() { |
||||
return "com/fr/plugin/hd/locale/lang"; |
||||
} |
||||
|
||||
@Override |
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
} |
@ -0,0 +1,87 @@
|
||||
/* |
||||
* Copyright (C), 2018-2022 |
||||
* Project: starter |
||||
* FileName: SheetPDFExporter |
||||
* Author: xx |
||||
* Date: 2022/4/29 16:25 |
||||
*/ |
||||
package com.fr.plugin.hd.export; |
||||
|
||||
import com.fanruan.api.i18n.I18nKit; |
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.io.exporter.PDFExporter; |
||||
import com.fr.main.workbook.ResultWorkBook; |
||||
import com.fr.page.PageSetCreator; |
||||
import com.fr.plugin.context.PluginContexts; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.web.core.ReportRepositoryDeal; |
||||
|
||||
import java.io.OutputStream; |
||||
import java.util.Arrays; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <SheetPDFExporter> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
public class SheetPDFExporter extends PDFExporter { |
||||
|
||||
public static final String USEFUL_SHEETS = "usefulSheets"; |
||||
|
||||
private int[] getUsefulSheets(Map<String, Object> reportParameterMap) { |
||||
if (!reportParameterMap.containsKey(USEFUL_SHEETS)) { |
||||
return null; |
||||
} |
||||
String usefulSheets = reportParameterMap.get(USEFUL_SHEETS).toString(); |
||||
LogKit.info("hd-SheetPDFExporter-getUsefulSheets-usefulSheets:{}", usefulSheets); |
||||
return Arrays.stream(usefulSheets.split(",")).mapToInt(Integer::parseInt).toArray(); |
||||
} |
||||
|
||||
@Override |
||||
public void export(OutputStream outputStream, ResultWorkBook resultWorkBook, PageSetCreator pageSetCreator, ReportRepositoryDeal reportRepositoryDeal, int[] ints) throws Exception { |
||||
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) { |
||||
LogKit.error(I18nKit.getLocText("Plugin-hd_Licence_Expired")); |
||||
super.export(outputStream, resultWorkBook); |
||||
return; |
||||
} |
||||
if (ints == null || ArrayUtils.getLength(ints) <= 0) { |
||||
ints = getUsefulSheets(reportRepositoryDeal.getReportParameterMap()); |
||||
} |
||||
ResultWorkBook useResultWorkBook = this.removeUselessSheet(resultWorkBook, ints, resultWorkBook); |
||||
super.export(outputStream, useResultWorkBook); |
||||
} |
||||
|
||||
@Override |
||||
public void export(OutputStream outputStream, ResultWorkBook resultWorkBook) throws Exception { |
||||
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) { |
||||
LogKit.error(I18nKit.getLocText("Plugin-hd_Licence_Expired")); |
||||
super.export(outputStream, resultWorkBook); |
||||
return; |
||||
} |
||||
int[] ints = getUsefulSheets(resultWorkBook.getExecuteParameters()); |
||||
ResultWorkBook useResultWorkBook = this.removeUselessSheet(resultWorkBook, ints, resultWorkBook); |
||||
super.export(outputStream, useResultWorkBook); |
||||
} |
||||
|
||||
private ResultWorkBook removeUselessSheet(ResultWorkBook resultWorkBook, int[] sheetIndexArray, ResultWorkBook handledResultWorkBook) { |
||||
if (ArrayUtils.isEmpty(sheetIndexArray)) { |
||||
return handledResultWorkBook; |
||||
} |
||||
if (resultWorkBook.getReportCount() > sheetIndexArray.length) { |
||||
try { |
||||
handledResultWorkBook = (ResultWorkBook) resultWorkBook.clone(); |
||||
for (int i = 0; i < resultWorkBook.getReportCount(); i++) { |
||||
if (!ArrayUtils.contains(sheetIndexArray, i)) { |
||||
handledResultWorkBook.removeReport(i); |
||||
} |
||||
} |
||||
} catch (Exception e) { |
||||
LogKit.error(e.getMessage(), e); |
||||
} |
||||
} |
||||
return handledResultWorkBook; |
||||
} |
||||
} |
@ -0,0 +1,45 @@
|
||||
/* |
||||
* Copyright (C), 2018-2022 |
||||
* Project: starter |
||||
* FileName: CustomPDFExporterCreator |
||||
* Author: xx |
||||
* Date: 2022/4/29 16:02 |
||||
*/ |
||||
package com.fr.plugin.hd.provider; |
||||
|
||||
import com.fanruan.api.log.LogKit; |
||||
import com.fr.io.exporter.*; |
||||
import com.fr.plugin.hd.export.SheetPDFExporter; |
||||
import com.fr.stable.fun.Authorize; |
||||
|
||||
import static com.fr.plugin.hd.LocaleFinder.PLUGIN_ID; |
||||
|
||||
/** |
||||
* <Function Description><br> |
||||
* <CustomPDFExporterCreator> |
||||
* |
||||
* @author xx |
||||
* @since 1.0.0 |
||||
*/ |
||||
@Authorize(callSignKey = PLUGIN_ID) |
||||
public class CustomPDFExporterCreator extends AbstractPDFExporterCreator { |
||||
|
||||
@Override |
||||
public PDFExporterProcessor createPDFExporter(boolean isPrint) { |
||||
LogKit.info("hd-CustomPDFExporterCreator-createPDFExporter-isPrint:{}", isPrint); |
||||
return isPrint ? new PDFExporterForPrint() : new SheetPDFExporter(); |
||||
} |
||||
|
||||
@Override |
||||
public PDFExporterProcessor createPDFExporter(PDFExportType pdfExportType) { |
||||
LogKit.info("hd-CustomPDFExporterCreator-createPDFExporter-pdfExportType:{}", pdfExportType); |
||||
switch (pdfExportType) { |
||||
case EXPORT: |
||||
return new SheetPDFExporter(); |
||||
case PRINT: |
||||
return new PDFExporterForPrint(); |
||||
default: |
||||
return new PDFEmbExporter(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,2 @@
|
||||
Plugin-hd=Export PDF Plugin |
||||
Plugin-hd_Licence_Expired=Export PDF Plugin Licence Expired |
@ -0,0 +1,2 @@
|
||||
Plugin-hd=Export PDF Plugin |
||||
Plugin-hd_Licence_Expired=Export PDF Plugin Licence Expired |
Loading…
Reference in new issue