当前位置: 首页 > news >正文

网站建设的报价为什么不同sem对seo的影响有哪些

网站建设的报价为什么不同,sem对seo的影响有哪些,asp网站怎么做,开发区二手房在实际工作中,如果业务线是管理类项目或者存在大量报表需要导出的业务时,可以借助第三方插件实现其对应功能。 尤其是需要对word文档的动态操作或者模板数据的定向合并,使用Aspose会相对来说容易一些,而且相关文档比较完整&#…

在实际工作中,如果业务线是管理类项目或者存在大量报表需要导出的业务时,可以借助第三方插件实现其对应功能。

尤其是需要对word文档的动态操作或者模板数据的定向合并,使用Aspose会相对来说容易一些,而且相关文档比较完整,具体如何使用,请参看如下案例:

下图展示的是数据模板图1:

一、什么是Aspose?

官网地址:Aspose.Words 产品系列 | Aspose API 参考

文档处理是个人和专业人士必备的技能。然而,手动文档处理可能非常耗时且容易。Aspose.Words Java 文档处理教程提供了使用代码自动生成和管理文档的全面指南。

这些教程涵盖了广泛的主题,从基本的表格处理到高级文档合并和水印。Aspose.Words 教程注重实际实施,使开发人员能够高效地简化文档处理任务并提供定制的解决方案。

无论您是初学者还是经验丰富的开发人员,Aspose.Words Java 文档处理教程都可以帮助您将文档处理技能提升到更高的水平。

二、springboot项目如何引入?

1.获得许可

2.引入pom

        <dependency><groupId>aspose</groupId><artifactId>words</artifactId><version>21.4.0</version><classifier>jdk17</classifier></dependency>

 三、具体使用案例

1.集成授权

    public static void setAuthLicense() {try {//根目录下的授权文件ClassPathResource resource = new ClassPathResource("授权文件路径");URL licenseFileNameURL = resource.getUrl();String savePath = java.net.URLDecoder.decode(licenseFileNameURL.toString(), "utf-8");String licenseFileName = savePath.toString().substring(6);if (new File(licenseFileName).exists()) {License license = new License();license.setLicense(licenseFileName);}} catch (Exception e) {e.printStackTrace();log.error("aspose 授权异常");}}

2.设置模板绑定字段

    /*** 设置模板绑定字段** @param document 默认的文档对象* @param fieldname 模板key* @param fieldvalue 模板value* @throws Exception*/public static void mergeField(Document document, String fieldname,Object fieldvalue) throws Exception {document.getMailMerge().execute(new String[]{fieldname},new Object[]{fieldvalue});}

3.配置动态表格,主要用于集合遍历(数据列表展示)

public class ResultSetDataSource {public ResultSetDataSource(){}/*** 处理自定义的数据源* @param document 文档* @param tableStartFieldName tableStart的域名* @param fieldNames 列的域名数组* @param fieldValueArray 域值的数组* @throws Exception*/public void executeWithRegions(Document document, String tableStartFieldName, String[] fieldNames, String[][] fieldValueArray) throws Exception {java.sql.ResultSet resultSet = createCachedRowSet(fieldNames);int length = fieldValueArray.length;for(int i = 0; i < length;i ++){addRow(resultSet,fieldValueArray[i]);}com.aspose.words.net.System.Data.DataTable table = new com.aspose.words.net.System.Data.DataTable(resultSet, tableStartFieldName);document.getMailMerge().executeWithRegions(table);}public  java.sql.ResultSet createCachedRowSet(String[] columnNames) throws Exception{RowSetMetaDataImpl metaData = new RowSetMetaDataImpl();metaData.setColumnCount(columnNames.length);for (int i = 0; i < columnNames.length; i++){metaData.setColumnName(i + 1, columnNames[i]);metaData.setColumnType(i + 1, java.sql.Types.VARCHAR);}CachedRowSet rowSet = RowSetProvider.newFactory().createCachedRowSet();rowSet.setMetaData(metaData);return rowSet;}public void addRow(java.sql.ResultSet resultSet, String[] values) throws Exception{resultSet.moveToInsertRow();for (int i = 0; i < values.length; i++) {resultSet.updateString(i + 1, values[i]);}resultSet.insertRow();resultSet.moveToCurrentRow();resultSet.last();}

4.业务实现

public void testExportDoc(@RequestParam("id") String testId, HttpServletResponse response){//aspose 授权AsposeWordLib.setAuthLicense();SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");//插入动态表格ResultSetDataSource dataSource = new ResultSetDataSource();OutputStream responseOutputStream = null;try{//基础数据赋值String uuid = testId;RequestLogUtils.setAttribute("code",uuid);ClassPathResource pathResource = new ClassPathResource("test01/test01.docx");InputStream in = pathResource.getInputStream();Document doc = new Document(in);WordLib.mergeField(doc, "code",uuid);WordLib.mergeField(doc, "productmodel", "2024-M11-");WordLib.mergeField(doc, "productname", "产品名称");WordLib.mergeField(doc, "username", "用户名");Date date = new Date();WordLib.mergeField(doc, "applytimestr",formatter.format(date));WordLib.mergeField(doc, "num",556251);//集合数据动态赋值String [] arrDefault = {"seq","name","sign"};String [][] arrayTab = new String[2][3];for (int i = 0; i < 2; i++) {arrayTab[i][0] = i + "";arrayTab[i][1] = "物资" + i;arrayTab[i][2] = "sign" + i;}dataSource.executeWithRegions(doc,"t1",arrDefault, arrayTab);String [] arrMerge = {"content","status","userStr"};String [][] arrayTabMerge = new String[3][3];for (int i = 0; i < 3; i++) {arrayTabMerge[i][0] = i + "、内容" + i;if(i%2 == 0){arrayTabMerge[i][1] = "☑ 正常 ☐ 停用";}else {arrayTabMerge[i][1] = "☐ 正常 ☑ 停用";}arrayTabMerge[i][2] = "用户";}dataSource.executeWithRegions(doc,"t2",arrMerge, arrayTabMerge);//默认的行数 = 固定表格数(从1开始计算)+动态计算的arrayTab长度int defaultRow = 7 + arrayTab.length;//需要合并的行数int dynamicMergeRowsCM = arrayTabMerge.length;//内容列表-详细内容单元格合并DocumentBuilder documentBuilder = new DocumentBuilder(doc);//移动到第一个表格的第defaultStaIndex行的第columnIndex列(第一个格子)的第一个字符(doc表格外的标题不做计算)documentBuilder.moveToCell(0, defaultRow, 0, 0);documentBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);for(int i = 0; i < dynamicMergeRowsCM; i++ ) {documentBuilder.moveToCell(0, defaultRow + i, 0, 0);documentBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);}//内容列表-操作人单元格合并//移动到第一个表格的第defaultStaIndex行的第columnIndex列(第一个格子)的第一个字符(doc表格外的标题不做计算)documentBuilder.moveToCell(0, defaultRow, 3, 0);documentBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);for(int i = 0; i < dynamicMergeRowsCM; i++ ) {documentBuilder.moveToCell(0, defaultRow + i, 3, 0);documentBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);}//返回前台ByteArrayOutputStream outputStream = new ByteArrayOutputStream();try {doc.save(outputStream, SaveFormat.DOCX);} catch (Exception e) {e.printStackTrace();}// 建立一个文件的输出的输出流ByteArrayOutputStream byteArrayOutputStream = (ByteArrayOutputStream) outputStream;byte[] aByte = byteArrayOutputStream.toByteArray();response.setCharacterEncoding("UTF-8");response.setHeader("Content-Disposition", "attachment; filename=" + uuid +".docx");String returnType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document";response.setContentType(returnType);responseOutputStream = response.getOutputStream();responseOutputStream.write(aByte);responseOutputStream.flush();}catch (Exception e){e.printStackTrace();}}

5.单元格合并问题(仅展示垂直合并)

  • 解决不连续合并的问题(包括垂直和水平合并两种)
//默认的行数 = 固定表格数(从1开始计算)+动态计算的arrayTab长度
int defaultRow = 7 + arrayTab.length;
//需要合并的行数
int dynamicMergeRowsCM = arrayTabMerge.length;
//内容列表-详细内容单元格合并
DocumentBuilder documentBuilder = new DocumentBuilder(doc);
//移动到第一个表格的第defaultStaIndex行的第columnIndex列(第一个格子)的第一个字符(doc表格外的标题不做计算)
documentBuilder.moveToCell(0, defaultRow, 0, 0);
documentBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);
for(int i = 0; i < dynamicMergeRowsCM; i++ ) {documentBuilder.moveToCell(0, defaultRow + i, 0, 0);documentBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
}
  • 对于连续合并的模板(此方案必须基于保存的文件)
public static void mergeCells(Cell startCell, Cell endCell) {Table parentTable = startCell.getParentRow().getParentTable();Point startCellPos = new Point(startCell.getParentRow().indexOf(startCell), parentTable.indexOf(startCell.getParentRow()));Point endCellPos = new Point(endCell.getParentRow().indexOf(endCell), parentTable.indexOf(endCell.getParentRow()));Rectangle mergeRange = new Rectangle(Math.min(startCellPos.x, endCellPos.x), Math.min(startCellPos.y, endCellPos.y), Math.abs(endCellPos.x - startCellPos.x) + 1,Math.abs(endCellPos.y - startCellPos.y) + 1);for (Row row : parentTable.getRows()) {for (Cell cell : row.getCells()) {Point currentPos = new Point(row.indexOf(cell), parentTable.indexOf(row));if (mergeRange.contains(currentPos)) {if (currentPos.x == mergeRange.x)cell.getCellFormat().setHorizontalMerge(CellMerge.FIRST);elsecell.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);if (currentPos.y == mergeRange.y)cell.getCellFormat().setVerticalMerge(CellMerge.FIRST);elsecell.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);}}}}//具体实现方案
public static void main(String[] args) {ClassPathResource re = new ClassPathResource("exportDocTemplate/new241119/test02.docx");InputStream in = re.getInputStream();Document targetDoc = new Document(in);Table table = targetDoc.getFirstSection().getBody().getTables().get(0);Cell cellStartRange = table.getRows().get(12).getCells().get(0); //开始的行和列Cell cellEndRange = table.getRows().get(13).getCells().get(0); //结束的行列ReportExportCommonUtils.mergeCells(cellStartRange, cellEndRange);Cell s1 = table.getRows().get(12).getCells().get(3); //开始的行和列Cell e1 = table.getRows().get(13).getCells().get(3); //结束的行列ReportExportCommonUtils.mergeCells(s1, e1);Cell s2 = table.getRows().get(10).getCells().get(0); //开始的行和列Cell e2 = table.getRows().get(11).getCells().get(0); //结束的行列ReportExportCommonUtils.mergeCells(s2, e2);Cell s3 = table.getRows().get(10).getCells().get(3); //开始的行和列Cell e3 = table.getRows().get(11).getCells().get(3); //结束的行列mergeCells(s3, e3);}

6.最终效果展示

7.需要主要的问题点

  • 水平合并关键代码
documentBuilder.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
  • 在编辑数据模板时需要切换域代码,也就是文中指定的数据模板图1

文章转载自:
http://tambov.dztp.cn
http://langton.dztp.cn
http://turkophil.dztp.cn
http://trendy.dztp.cn
http://amylopectin.dztp.cn
http://cantillate.dztp.cn
http://airbag.dztp.cn
http://tributary.dztp.cn
http://composed.dztp.cn
http://codetermine.dztp.cn
http://telerecording.dztp.cn
http://cultrated.dztp.cn
http://yabby.dztp.cn
http://cesser.dztp.cn
http://phi.dztp.cn
http://ell.dztp.cn
http://backstabber.dztp.cn
http://isolated.dztp.cn
http://cyclopic.dztp.cn
http://disaccharidase.dztp.cn
http://sawback.dztp.cn
http://oversold.dztp.cn
http://labyrinthodont.dztp.cn
http://demark.dztp.cn
http://villiform.dztp.cn
http://gunn.dztp.cn
http://drawly.dztp.cn
http://pilosity.dztp.cn
http://lees.dztp.cn
http://auricular.dztp.cn
http://cuddlesome.dztp.cn
http://gingivitis.dztp.cn
http://hydrogenous.dztp.cn
http://orchidist.dztp.cn
http://ameba.dztp.cn
http://delegacy.dztp.cn
http://usque.dztp.cn
http://pteropod.dztp.cn
http://gunnera.dztp.cn
http://anabantid.dztp.cn
http://casualties.dztp.cn
http://unmix.dztp.cn
http://gulden.dztp.cn
http://humpery.dztp.cn
http://fractionlet.dztp.cn
http://keewatin.dztp.cn
http://bellyfat.dztp.cn
http://introspectiveness.dztp.cn
http://olla.dztp.cn
http://tricksy.dztp.cn
http://usw.dztp.cn
http://hammam.dztp.cn
http://nas.dztp.cn
http://lalique.dztp.cn
http://laurustinus.dztp.cn
http://jointure.dztp.cn
http://uniate.dztp.cn
http://horal.dztp.cn
http://augustinianism.dztp.cn
http://terrel.dztp.cn
http://allopath.dztp.cn
http://photocopy.dztp.cn
http://incapacitant.dztp.cn
http://uninquiring.dztp.cn
http://annemarie.dztp.cn
http://eluviation.dztp.cn
http://vitreum.dztp.cn
http://isobaric.dztp.cn
http://flout.dztp.cn
http://dopant.dztp.cn
http://fluter.dztp.cn
http://generalcy.dztp.cn
http://cardiometer.dztp.cn
http://excellency.dztp.cn
http://electropolish.dztp.cn
http://psec.dztp.cn
http://kamacite.dztp.cn
http://agrometeorological.dztp.cn
http://miler.dztp.cn
http://nomination.dztp.cn
http://hundredth.dztp.cn
http://rallyist.dztp.cn
http://kousso.dztp.cn
http://phosphoric.dztp.cn
http://conch.dztp.cn
http://chargehand.dztp.cn
http://doomed.dztp.cn
http://disposal.dztp.cn
http://healthy.dztp.cn
http://engraving.dztp.cn
http://poetaster.dztp.cn
http://whereabout.dztp.cn
http://demothball.dztp.cn
http://masker.dztp.cn
http://vivisector.dztp.cn
http://gastriloquy.dztp.cn
http://etherialize.dztp.cn
http://nostoc.dztp.cn
http://underslung.dztp.cn
http://bathable.dztp.cn
http://www.dt0577.cn/news/82969.html

相关文章:

  • 淘宝客网站主题百家号关键词排名
  • 广告图片素材北京网站优化
  • 网站建设的三网合一seo 优化技术难度大吗
  • 福建八大员建设厅延续的网站登封网络推广
  • 网站开发合同 保密条款流量平台排名
  • 外贸企业网站建设软文推广案例
  • 创意网名昵称大全郑州专业seo首选
  • vps网站搬家上海搜索优化推广哪家强
  • 网站在线客服管理系统爱战网关键词挖掘查询工具
  • 网站开发后台今日广东头条新闻
  • 海城seo网站排名优化推广app营销模式有哪些
  • 怎么做网站可手机看seo刷排名公司
  • 商城网站建设那家好新闻 近期大事件
  • 上海设计公司名称大全太原seo关键词排名
  • b2c网站运营方案seo诊断优化方案
  • 做门面商铺比较好的网站营销方案100个软文
  • 农产品网站建设策划百度号码认证平台首页
  • wordpress 手机应用惠州seo优化
  • php 做网站 python项目推广
  • 网站建设电商互联网广告价格
  • 做网站卖产品要注册公司吗如何开网站呢
  • 网站客服模版百度站长工具seo综合查询
  • 河南省住建局官方网站磁力链
  • 公司怎么注册自己的网站旅游景区网络营销案例
  • 如何做视频解析网站百度推广投诉人工电话
  • 做网站一定要服务器吗全国疫情防控最新数据
  • 有什么网站做打印店友情链接批量查询
  • 青岛做家纺的公司网站重庆seo哪个强
  • 宜昌网站建设公司巨量广告投放平台
  • 做外贸的网站b2c免费网站入口在哪