Aspose.Cells可以预先定义Excel模板,然后填充数据(官方文档:http://www.aspose.com/docs/display/cellsjava/Smart+Markers)。

设置的模板是一个标准的Excel文件,包含了可视化的格式,公式,以及标记(smart markers),并且可以引用多个数据源。

支持的标记(Smart Marker Options)

&=DataSource.FieldName 数据元是ICellsDataTable或者是JavaBean
&=[Data Source].[Field Name] 数据源是 ResultSet
&=$VariableName  一个变量
&=$VariableArray 数组变量
&==DynamicFormula 暂时不清楚
&=&=RepeatDynamicFormula 动态计算

下面介绍这两种标记的使用方式

1、&=$VariableName  一个变量
2、&=$VariableArray 数组变量

Java代码

     String path = "SmartMarkerDesigner.xls";
InputStream inputStream = ClassLoader.getSystemResourceAsStream(path);
Workbook wb = new Workbook(inputStream);
WorkbookDesigner designer = new WorkbookDesigner();
designer.setWorkbook(wb);
designer.setDataSource("Variable", "Single Variable");
designer.setDataSource("MultiVariable", new String[]
{
"Variable 1", "Variable 2", "Variable 3"
});
designer.setDataSource("MultiVariable2", new String[]
{
"Skip 1", "Skip 2", "Skip 3"
});
designer.setDataSource("Array1Dim", new String[]
{
"A1", "A2", "A3"
});
designer.setDataSource("Array2Dim", new String[][]
{
{
"A11", "A12", "A13"
},
{
"A21", "A22", "A23", "A24"
},
{
"A31", "A32",
},
});

下面介绍JavaBean的使用方式

&=DataSource.FieldName 数据元是ICellsDataTable或者是JavaBean

&=Person.name(bean) 注意这个地方需要加上bean

其中&=&=C{r}*D{r} 是动态计算的标记

&=&= 构面跟一个表达式 r代表当前行,C{r}*D{r} 这样在循环的时候没一行都会计算。

上面的例子用id这列进行分组Grouping Data

normal - The group by field(s) value is not be repeated for the corresponding records in the column; instead they are printed once per data group.

分组的列不会被循环输出,只会输出一次。

merge - The same behavior as for the normal parameter, except that it merges the cells in the group by field(s) for each group set.

和normal一样,但是他会合并单元格

repeat - The group by field(s) value is repeated for the corresponding records.

分组的列会循环输出

&=subtotal9:Person.id 放在那一列下面是按照id进行分组统计。

或者&=Employee.money(subtotal9:Employee.id) 这么写也行,按照id进行分组统计

subtotalN (N的值可以是1-11 平均数 总行数 最大值 最小值 总和 等等。)

Performs a summary operation for a specified field data related to a group by field. The N represents numbers between 1 and 11 which specify the function used when calculating subtotals within a list of data. (1=AVERAGE, 2=COUNT, 3=COUNTA, 4=MAX, 5=MIN,...9=SUM etc.) Refer to the Subtotal reference in Microsoft Excel's help for further details.

The format actually states as:
subtotalN:Ref where Ref refers to the group by column.

&=Products.Units(subtotal9:Products.ProductID) specifies summary function upon Units field with respect to the ProductID field in the Products table.

&=Tabx.Col3(subtotal9:Tabx.Col1) specifies summary function upon the Col3 field group by Col1 in the table Tabx.

&=Table1.ColumnD(subtotal9:Table1.ColumnA&Table1.ColumnB) specifies summary function upon ColumnD field group by ColumnA and ColumnB in the table Table1.

Aspose.Cells Smart markers 基于模板导出Excel的更多相关文章

  1. aspose.cells根据模板导出excel

    又隔十多天没写博客了,最近都在忙项目的事情,公司人事变动也比较大,手头上就又多了一个项目.最近做用aspose.cells根据模板导出excel报价单的功能,顺便把相关的核心记下来,先上模板和导出的效 ...

  2. ASP.NET Core 2.2 : 十六.扒一扒新的Endpoint路由方案 try.dot.net 的正确使用姿势 .Net NPOI 根据excel模板导出excel、直接生成excel .Net NPOI 上传excel文件、提交后台获取excel里的数据

    ASP.NET Core 2.2 : 十六.扒一扒新的Endpoint路由方案   ASP.NET Core 从2.2版本开始,采用了一个新的名为Endpoint的路由方案,与原来的方案在使用上差别不 ...

  3. Java无模板导出Excel,Apache-POI插件实现

    开发环境 jdk 1.8 Maven 3.6 Tomcat 8.5 SpringBoot 2.1.4.RELEASE Apache-POI 3.6 Idea 注意: 我是在现有的基于SpringBoo ...

  4. poi根据excel模板导出Excel

    /****单元格值对象**/public class Cells { /*** * 行 */ private int row; /** * 列 */ private int column; /** * ...

  5. POI通过模板导出EXCEL文件

    一般的EXCEL导出使用POI先创建一个HSSFWorkbook,然后通过不断创建HSSFRow,HSSFCell后设置单元格内容便可以完成导出. 这次在项目中需要用到模板,导出的内容包括(1.模板中 ...

  6. .Net NPOI 根据excel模板导出excel、直接生成excel

    一.根据Excel模板导出excel 1.导入NPOI.dll  2.DAL中添加类ExportExcel.cs using NPOI.SS.UserModel; using System; usin ...

  7. apache poi根据模板导出excel

    需要预先新建编辑好一个excel文件,设置好样式. 编辑好输出的数据,根据excel坐标一一对应. 支持列表数据输出,列表中列合并. 代码如下: package com.icourt.util; im ...

  8. 按模板导出Excel

    说明:开发环境 vs2012 asp.net mvc4 c# 注意:Excel模板有多个sheet页,导出Excel的时候,同时给多个sheet页填充数据 1.项目结构 3.Excel模板(注意she ...

  9. NPOI复制模板导出Excel

    本人菜鸟实习生一枚,公司给我安排了一个excel导出功能.要求如下:1.导出excel文件有样式要求:2.导出excel包含一个或多个工作表:3.功能做活(我的理解就是excel样式以后可能会变方便维 ...

随机推荐

  1. 【转载】Eclipse中.setting目录下文件介绍

    原文:http://blog.csdn.net/huaweitman/article/details/52351394 Eclipse在新建项目的时候会自动生成一些文件.这些文件比如.project. ...

  2. U811.1接口EAI系列之二-BOM构成-委外BOM构成--VB语言

    1.下面代码实现了VB6.0中调用U8EAI-BOM构成服务,以下代码均为项目实际代码,可直接复制应用. 2.在u811.1版本中委外BOM构成与正常的BOM构成是同系列表,不单独存储. 3.是以存货 ...

  3. spring 项目中在类中注入静态字段

    有时spring 项目中需要将配置文件的属性注入到类的静态字段中 例如:文件上传 //文件上传指定上传位置 //resource-dev.properties 有如下参数 #upload UPLOAD ...

  4. Linux 系统结构详解【转】

    Linux系统一般有4个主要部分: 内核.shell.文件系统和应用程序.内核.shell和文件系统一起形成了基本的操作系统结构,它们使得用户可以运行程序.管理文件并使用系统.部分层次结构如图1-1所 ...

  5. pm2 设置开机启动

    一.官方文档: 官方相关文档:http://pm2.keymetrics.io/docs/usage/startup/#generating-a-startup-script 二.具体操作过程如下: ...

  6. centos安装Elasticsearch步骤

    1.安装JDK:centos删除openJDK,安装JDK,vim /etc/profile配置JAVA_HOME 2.官网下载elasticsearch:https://www.elastic.co ...

  7. eclipse 运行 emulator时,PANIC:Could not open emulator 的解决办法

    使用eclipse启动emulator的时候,出现PANIC:Could not open emulator,模拟器无法正常的运行. 经过搜索得知,因为我的SDK的环境变量出问题,需要重新配置下环境变 ...

  8. 给现有MVC项目增加Web API支持

    在MVC4中自带了Web API不再需要从Nuget中下载. Step1:增加System.Web.Http,System.Web.Http.WebHost,System.Net.Http三个程序集的 ...

  9. IReport5.6.0创建数据库连接找不到驱动(iReport中ClassNotFoundError错误的解决)

    情景:iRoport中选择com.microsoft.jdbc.sqlserver.SQLServerDriver的JDBC Driver;连接时出现ClassNotFoundError错误 当见到下 ...

  10. MariaDB/MySql 服务消失无法启动

    今天启动电脑打开数据库发现这么一个错误:  2003 can't connect to mysql server on localhost 10038  无奈去查看了服务,发现mysql服务消失了,猜 ...