Idea

8
Replies
863
Views
okar1 Member since 2016 13 posts
PEGA
Posted: 3 years ago
Last activity: 6 months 3 weeks ago

CSV export & import function for Japanese with Excel

Hi I am writting this post for Japanese customer but I belive any countries who use double-byte are facing same issue. So, I would like to have more opinition for my request.

[Description]
Many of Japanese customers want to use Excel for CSV import & Export. However, CSV import & export's character code for v7.2 is UTF-8.
Saving file in Excel with Japanese character will generate a CSV file with Shift-JIS, so we are not able to import file by using "pxUploadCSVResults" for import and " ConvertResultsToCSV " for export.
* This is a default behaviour of Excel if there is Japanese characters but other language such as Korea, Chines may be facing a same problem.
Request are:
1. to have parameters or something else to specify import character code for "pxUploadCSVResults"
2. to have parameters or something else to specify with BOM or without BOM for "ConvertResultsToCSV "

Here are details for these requests:
[1. Import]
Step2 (java) in "pxUploadCSVResults"

we comment the line below
//cofileContent = new com.pega.pegarules.pub.util.Base64Util().decode(strFileData);

And then add 3 lines below instead
try {
fileContent = new String(org.apache.commons.codec.binary.Base64.decodeBase64(strFileData),"MS932");
} catch (java.io.UnsupportedEncodingException e) {
}

However, "pxUploadCSVResults" is Final, so we do not want to modify code in Step2.
Rather we want to have a parameter, which we can specify "character code" to use for import action

[2. Export]
Step 5 (java) in "ConvertResultsToCSV", we had to add 3 line for steam to add BOM to properly open UTF-8 file with Excel
Because, Excel do not recognize CSV file without BOM. Therefore, we want to have an option to "set BOM" somewhere in "ConvertResultsToCSV".

try{
// Create file
PROutputStream stream = new PROutputStream(f);

// adding BOM to file stream
stream.write(0xef);
stream.write(0xbb);
stream.write(0xbf);

PRWriter out = new PRWriter(stream, null, false);

[Important notice]

Both rules are final, so we can not modify code

[Attempted Solutions]

We modified few lines of Java code to work properly with Excel file.
Please see attached screen shots and CSV file with Shift-JIS.

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

SR Exists
Share this page LinkedIn