报表知识库
我要提问

统一修改填报属性“模式”,而不修改其它属性

问题描述:
     由于报表用户更换了数据库,需要重新更改报表中填报功能里的更新属性。报表用户想通过API实现只统一修改报表模式属性,而不修改其它属性。
  
问题解决方法:
     API
代码代码如下:
import com.runqian.report4.model.ReportDefine;

import com.runqian.report4.usermodel.INormalCell;

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;

 

public class Update {

    public static void main(String[] args) {

        try{

            ReportDefine rd = (ReportDefine)ReportUtils.read(“D:/1.raq”);

 

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

                for(short c=1;c<=rd.getColCount();c++){

                    // 获取填报属性

                    INormalCell cell = rd.getCell(r, c);

 

                    InputProperty ip = cell.getInputProperty();

                    if(ip==null || ip.getUpdateList()==null) continue;

                    // 获取更新属性

                    UpdateProperty up = (UpdateProperty)ip.getUpdateList().get(0);

                    Object relations = up.getRelation();

                    TableRelations trs = (TableRelations)relations;

                    trs.setSchema(“TEST”);

                }

            }

            ReportUtils.write(“D:/2.raq”, rd);

            System.out.println(“done!”);

        }

        catch(Exception e){

            e.printStackTrace();

        }

    }

}

标签: