EAS BOS 报表添加合计行,和每行合计
来源:互联网 发布:qstring转char数组 编辑:程序博客网 时间:2024/05/17 10:54
/**
* 添加报表合计行
* @param table
* @param fieldSumList 需要合计列
*/
public static void appendFootRow(KDTable table, List fieldSumList) {
Map columnMap = new HashMap();
columnMap.clear();
KDTable tableSum = table;
for (int j = 0; j < fieldSumList.size(); ++j) {
String Number = (String) fieldSumList.get(j);
if (Number != null) {
BigDecimal dbSum = new BigDecimal("0");
for (int r = 0; r < tableSum.getRowCount(); ++r) {
if (tableSum.getRow(r).getStyleAttributes().isHided()) {
continue;
}
ICell cell = tableSum.getRow(r).getCell(Number);
String cellValue = tableSum.getCellDisplayText(cell);
if (cellValue != null) {
cellValue = cellValue.toString().replaceAll(",", "");
}
if (!StringUtility.isNumber(cellValue)) {
Object cellObj = cell.getValue();
if (cellObj != null)
cellValue = cellObj.toString();
if (!StringUtility.isNumber(cellValue)) {
continue;
}
}
BigDecimal bigdem = new BigDecimal(String
.valueOf(cellValue).trim());
dbSum = dbSum.add(bigdem);
}
String strSum = dbSum.toString();
columnMap.put(Number, strSum);
}
}
if (columnMap.size() > 0) {
IRow footRow = tableSum.addRow();
String colFormat = "%{#,###.##########}f";
String total = EASResource
.getString("com.kingdee.eas.framework.FrameWorkResource.Msg_Total");
tableSum.getIndexColumn().setWidthAdjustMode((short) 1);
tableSum.getIndexColumn().setWidth(30);
footRow.getCell(0).setValue(total);
footRow.getStyleAttributes()
.setBackground(new Color(246, 246, 191));
footRow.getStyleAttributes().setNumberFormat(colFormat);
footRow.getStyleAttributes().setHorizontalAlign(
Styles.HorizontalAlignment.getAlignment("right"));
footRow.getStyleAttributes().setFontColor(Color.BLACK);
Iterator valueIterator = columnMap.entrySet().iterator();
while (valueIterator.hasNext()) {
Map.Entry colEntry = (Map.Entry) valueIterator.next();
String colIndex = (String) colEntry.getKey();
String colValue = (String) colEntry.getValue();
footRow.getCell(colIndex).setValue(colValue);
}
}
}
----------------------------------------------------------------------------------------------
//这里合计所有以"F"打头列名行,如果需要指定合计列只需要添加列参数即可,需求预先添加合计列:Total
public static void appendTotal(KDTable table)
{
Map columnMap = new HashMap();
int rowCount = table.getRowCount();
KDTColumns columns = table.getColumns();
for (int i = 0; i <rowCount ; i++) {
BigDecimal dbSum = new BigDecimal("0");
for (int j = 0; j < columns.size(); j++) {
KDTColumn column = columns.getColumn(j);
String fieldName = column.getKey();
if (fieldName.startsWith("F")) { //判断是否 F 打头的列名
ICell cell = table.getRow(i).getCell(fieldName);
String cellValue = table.getCellDisplayText(cell);
if (cellValue != null) {
cellValue = cellValue.toString().replaceAll(",", "");
}
if (!StringUtility.isNumber(cellValue)) {
Object cellObj = cell.getValue();
if (cellObj != null)
cellValue = cellObj.toString();
if (!StringUtility.isNumber(cellValue)) {
continue;
}
}
BigDecimal bigdem = new BigDecimal(String
.valueOf(cellValue).trim());
dbSum = dbSum.add(bigdem);
}
}
String strSum = dbSum.toString();
columnMap.put(i, strSum);
}
Iterator valueIterator = columnMap.entrySet().iterator();
while (valueIterator.hasNext()) {
Map.Entry colEntry = (Map.Entry) valueIterator.next();
Integer rowIndex = (Integer) colEntry.getKey();
String colValue = (String) colEntry.getValue();
table.getCell(rowIndex, "Total").setValue(colValue);
}
}
-------------
代码调用:
SzReportUtils.appendFootRow(tblMain, fieldSumList);
SzReportUtils.appendTotal(tblMain);
- EAS BOS 报表添加合计行,和每行合计
- EAS Bos 合计行代码
- EAS Bos 合计行代码
- EAS Bos 合计行代码
- EAS Bos 合计行代码(主要针对报表类的table)
- EAS BOS 绑定QUERY的列表界面,代码添加合计脚
- EAS BOS 绑定QUERY的列表界面,代码添加合计脚
- EAS BOS 绑定QUERY的列表界面,代码添加合计脚
- 金蝶EAS,BOS,KDTable表格增加普通行、合计行,需先解析表格
- datagrid中添加合计行计算合计
- 添加合计行
- 报表之惑----C#如何添加合计行?
- GridView添加统计(合计)行
- GridView添加统计(合计)行
- datagridview中添加合计行
- GridView添加统计(合计)行
- DataGridView底部添加合计行
- GridView添加统计(合计)行
- 使用JFreeChart创建饼图
- Domino下C/S与B/S模式的区别与优劣
- jsonkit 解析nsarray 时候 报错
- RFC3581——SIP中的rport机制
- 利用Eclipse来自动生成JavaBean的getter和setter方法
- EAS BOS 报表添加合计行,和每行合计
- 黑马程序员————IO技术小结(第三篇)
- perl函数说明(fcntl)
- hibernate注解
- 格雷厄姆《聪明的投资者》学习笔记
- Redis安装方法(小白专用)
- hdu 3518 ( 后缀数组 至少出现两次的不重叠子串个数)
- 【hoj】1196 Power Crisis( Joseph'problem 变型)、1441 Eeny Meeny Moo
- Android Studio的Gradle错误解决方法