将csv文件附加到工作对象

时间:2017-05-30 15:45:43

标签: pega

我有一个XML文件,我必须在CSV文件中转换然后附加到工作对象中?

我已经尝试过写一个活动并使用pxConvertResultsToCSV活动,然后尝试使用链接对象方法附加文件,但是这样所有结果都会出现在一行中。

1 个答案:

答案 0 :(得分:0)

几乎没有步骤......

1)使用活动方法Apply-Parse-XML解析XML。    您将在PageList

中获取XML数据

2)现在创建Rule-Obj-Html规则。在代码部分创建表

<table border="1">    
<pega:forEach name="YourPageListPage.PageList"> // --> the pagelist in which got the info from xml.

<tr>    
   <TD>
     <pega:reference name="$THIS.COLUMN1"/> // --> property name
  </TD>
  <TD>
     <pega:reference name="$THIS.COLUMN2"/> // --> property name 2
  </TD>
      </tr>
    </pega:forEach>
</table>

3)现在使用Property-Set-HTML在一些param变量中获取html规则的流(例如 param.pyFileData ) 还要将一个局部变量创建为 strFileData

使用Java步骤解码流。并使用此代码。

 String atr = (String)tools.getParameterPage().getParameterValue("pyFileData");

byte[] byteArray=(byte[])atr.getBytes();

//encode the byte array into Base64.
 strFileData = Base64Util.encodeToString(byteArray); // strFileData is local variable mentioned in activity.

4)现在创建一个类Data-WorkAttach-File的页面,并在该页面上设置以下属性。

.pxRefObjectKey --> pzinskey of work object
.pxAttachKey    --> any key, maybe current date time
.pyAttachStream --> your stream which you got from 3rd step (local.strFileData )
.pyNote         --> any note
.pxAttachName   --> "filename.csv"

休息我猜已经知道..  使用Obj-Save

保存此页面

5)使用Link-Objects将附件页面附加到工作对象。

多数民众赞成。