怎样使用API修改“是否更新未修改的行”

需求描述

需要动态修改更新属性中的”是否更新未修改的行”。

需求实现

示例代码如下:

package com;

import java.io.FileInputStream;

import java.io.FileNotFoundException;

import java.io.FileOutputStream;

import java.io.InputStream;

import java.io.OutputStream;

import java.util.ArrayList;

import com.runqian.report4.model.ReportDefine;

import com.runqian.report4.model.engine.ExtCellSet;

import com.runqian.report4.usermodel.Context;

import com.runqian.report4.usermodel.Engine;

import com.runqian.report4.usermodel.INormalCell;

import com.runqian.report4.usermodel.IReport;

import com.runqian.report4.usermodel.input.InputProperty;

import com.runqian.report4.usermodel.input.TableRelations;

import com.runqian.report4.usermodel.input.UpdateProperty;

import com.runqian.report4.util.ReportUtils;

import com.runqian.report4.view.html.HtmlReport;

public class FixUpdatePropertyMain {

public static void main(String[] args) throws Throwable {

System.out.println(“1111″);

String lisenseFile = “D:\\Program Files (x86)\\reportHome4541\\ 润乾 license\\ 内部测试使用 Server2012-12-31V4.0Windows.lic”;

ExtCellSet.setLicenseFileName(lisenseFile);

String reportFile = “D:\\Program Files (x86)\\MyEclipse 8.5\\Workspaces\\mydemo1.6\\WebRoot\\reportFiles\\test_ 更新属性 .raq”;

InputStream is;

try {

is = new FileInputStream(reportFile);

ReportDefine rd = (ReportDefine)ReportUtils.read( is);

for(int i=1;i<=rd.getRowCount();i++){

for(int j=1; j<=rd.getColCount();j++){

INormalCell ic = rd.getCell(i, (short)j);

// 如果单元格填报属性不为 null 且更新列表不为 null ,则再根据更新的表名进行判断是否修改”是否更新未修改的行”属性

if(ic.getInputProperty()!=null&&ic.getInputProperty().getUpdateList()!=null){

InputProperty ip = ic.getInputProperty();

ArrayList al = ip.getUpdateList();

int len = al.size();

System.out.println(“len=”+len);

ArrayList ups = new ArrayList(len);

for(int k=0;k<len;k++){

UpdateProperty up = (UpdateProperty)al.get(k);

Object relations = up.getRelation();

TableRelations trs = (TableRelations)relations;

System.out.println(“trs.getTableName()=”+trs.getTableName());

if(trs.getTableName().equals(“E7_STA_REPINST”)){

// 如果更新的是报表实例表,则不更改”是否更新未修改的行”属性

}else

{

trs.setUpdateUnmodified(false);// 设置”是否更新未修改的行”为未选中

}

up.setRelation(trs);

ups.add(up);

}

ip.setUpdateList(ups);

ic.setInputProperty(ip);

rd.setCell(i,(short)j, ic);

}

}

}

OutputStream out1 = new FileOutputStream( “D:\\Program Files (x86)\\MyEclipse 8.5\\Workspaces\\mydemo1.6\\WebRoot\\reportFiles\\test_ 更新属性 _fix.raq” );

ReportUtils.write(out1,rd);

out1.close();

System.out.println(“222″);

} catch (Exception e) {

e.printStackTrace();

}

}

}

热门文章