the problem of the Chinese code

Stimulsoft Reports.JAVA discussion
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: the problem of the Chinese code

Post by Vadim »

Hello.
Can you send us .mrt file with this wrong symbols in datasource ?
heqichao
Posts: 113
Joined: Fri Mar 04, 2016 9:02 am

Re: the problem of the Chinese code

Post by heqichao »

Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: the problem of the Chinese code

Post by Vadim »

Hello.
This name is broken, You should reenter chinese names again & save file.
heqichao
Posts: 113
Joined: Fri Mar 04, 2016 9:02 am

Re: the problem of the Chinese code

Post by heqichao »

hello, I don't know what's your mean, when I save the report the name is broken.
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: the problem of the Chinese code

Post by Vadim »

Hello.
We tried your report - words broken and then we reenter chinese characters and save. Then no broken characters in report.
heqichao
Posts: 113
Joined: Fri Mar 04, 2016 9:02 am

Re: the problem of the Chinese code

Post by heqichao »

Hello,there are broken characters but I just create the mysql connection ,and I don't know how are you create dataSource.
Image
Image
heqichao
Posts: 113
Joined: Fri Mar 04, 2016 9:02 am

Re: the problem of the Chinese code

Post by heqichao »

Hello , and what about this problem?
heqichao wrote:Hello, it is a problem about Chinese disorder code.
I use json dataSource and the data is this,
Image

but the Chinese Disorder Code in the report.
Image

it is my report .Thank you.
http://test.arp.cn/appendix/M00/00/1A/C ... IN_RPT.mdc
Vadim
Posts: 363
Joined: Tue Apr 23, 2013 11:23 am

Re: the problem of the Chinese code

Post by Vadim »

Hello.
As we see mdc file have wrong data
<item45 Ref="47" bh="Transparent" br="All;Black;1;Solid;False;4;Black" fn="MICROSOFT YAHEI UI,10" ha="Center" isSer="true" mr="0,0,0,0" name="Text54" pl="d.DataBand4" rc="2.4,5,3.8,1" tb="Black" text="转��方预算负责人审批" type="Text" va="Center" />
can you send us .mrt file with data
heqichao
Posts: 113
Joined: Fri Mar 04, 2016 9:02 am

Re: the problem of the Chinese code

Post by heqichao »

Hello ,this is my code

Code: Select all

public static StiReport getReport(String reportPath,String httpQueryUrl){
			 StiReport stiReport = null;
			 try {
				 stiReport = StiSerializeManager.deserializeReport(new File(reportPath));
			     stiReport.getDictionary().getDataSources().clear();
			     stiReport.getDictionary().getDatabases().clear();
				 stiReport.getDictionary().getRelations().clear();
				 StiJsonDatabase db = null;
				 if(stiReport.getDictionary().getDatabases().get("JSON")== null){
					  db = new StiJsonDatabase("JSON",httpQueryUrl);
	            	  stiReport.getDictionary().getDatabases().add(db);
				 }else{
					 db=(StiJsonDatabase) stiReport.getDictionary().getDatabases().get("JSON");
				 }
            	
	              JSONObject resuleObj =db.getJSONObject();
	              //TODO
	              JSONObject obj =resuleObj.getJSONObject("obj");
	              for(String ojbKey : obj.getNames(obj)){
	            	   JSONArray list =(JSONArray) obj.get(ojbKey);
	            	   StiDataTableSource ts = new StiDataTableSource("JSON"+"."+ojbKey, ojbKey, ojbKey);
			           ts.setColumns(new StiDataColumnsCollection());
				       Map keyMap =ReportUtil.getJsonArrayKey(list, new HashMap());
				        for(Object key :keyMap.keySet()){
				        	 ts.getColumns().add(new StiDataColumn((String)key, (String)key, StiSystemTypeEnum.SystemString.getSystemType()));
				        }
				        ts.setDictionary(stiReport.getDictionary());
				        stiReport.getDictionary().getDataSources().add(ts); 
	              }
              } catch (Exception e) {
					e.printStackTrace();
			}
	        stiReport.Render(false);
	        return stiReport;
		}


public static Map getJsonArrayKey(Object obj,Map keyMap){
			if(obj instanceof JSONArray){
				JSONArray jsonArray =(JSONArray) obj;
				int length = jsonArray.length();
				for(int i=0;i<length;i++){
					try {
						JSONObject jsonObject =jsonArray.getJSONObject(i);
						String[] names=JSONObject.getNames(jsonObject);
						for(String name :names){
							keyMap.put(name, name);
						}
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
			else if(obj instanceof JSONObject){
				JSONObject jsonObject =(JSONObject) obj;
				String[] keys=JSONObject.getNames(jsonObject);
				for(String key : keys){
					try {
						if(jsonObject.get(key) instanceof JSONArray){
							getJsonArrayKey(jsonObject.get(key), keyMap);
						}
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			}
			return keyMap;
		}



and is my report and the json data :
http://test.arp.cn/appendix/M00/00/1B/C ... IN_RPT.mrt
http://test.arp.cn/appendix/M00/00/1B/C ... =json.json

and this my http request
Image
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: the problem of the Chinese code

Post by Alex K. »

Hello,

We need some additional time for investigating the issue.
We will try to add the additional changes within two or three weeks.

We will let you know about the result.
Thank you.
Post Reply