Question

7
Replies
676
Views
Yasantha Member since 2016 3 posts
Virtusa
Posted: November 21, 2016
Last activity: November 30, 2016
Closed
Solved

How to convert an (.xls) file exported from report scheduler to (.csv)

Hi,

I have this requirement to schedule a report to generate weekly and save into a specific server location. Saving part is already implemented by customizing the 'pyTaskOutputProcessor(Pega-ScheduledTask-Reporting)' activity by adding a java step. In the function, it looks for the (.xls) file created while the scheduler runs and move it to the specific server location. 

Upto this point, everything is fine. But the requirement is to create a (.csv) file in the server location. Not an (.xls) file. The issue is, pega creates the (.xls) file with (html) content inside. So actually it's not a real (.xls) file. I tried converting the OOTB (.xls) file using Apache POI(com.pega.apache.poi) API. But it doesn't accept the input stream since it's inner contents doesn't match the valid excel format. Is there any way I can achieve this? Any way to convert the pega created (.xls) file with (html) inside into (.csv)?

Any help is mostly appreciated.

Follwing is the code I'm using to move the OOTB file into my location.

try{  
  PRFile source = new PRFile(SourceFile);
  java.io.File dest = new java.io.File(DestinationPath);
  java.io.File parentDir = dest.getParentFile();
  parentDir.mkdirs();  
  input = new PRInputStream(source);
  output = new java.io.FileOutputStream(dest);
  byte[] buf = new byte[1024];
  int bytesRead;
     while((bytesRead=input.read(buf))>0){  
           output.write(buf, 0, bytesRead);    
     }
  input.close();
  output.close();
  returnMsg = "success";  
} catch(Exception ex) {  
  returnMsg = "Coludn't copy file from " + SourceFile + " to " + DestinationPath + "          " + ex.getMessage();  
}

Thanks,

Yasantha.

Pega Version : 7.2

***Updated by moderator: Lochan to add Categories; add SR Exists group tag; add enhancement request details***

Data Integration Reporting SR Exists
Moderation Team has archived post
Share this page LinkedIn