Home > Database > Mysql Tutorial > 导出结果跟查询结果不一致_MySQL

导出结果跟查询结果不一致_MySQL

WBOY
Release: 2016-06-01 12:59:03
Original
1361 people have browsed it

1、错误原因

\ \

 

2、错误原因

上面左侧图是SQL语句查询出来的结果,右侧是导出Excel展示的数据,结果发现两者竟然不一致

 

3、解决办法

拼接的SQL:

 

sql.append("SELECT  CONCAT((@rowNum := @rowNum + 1),'') AS rownum,t.* FROM(");
Copy after login

导出中的赋值:

Map<string,object> map=(Map<string, object="">) data.get(i);
            	HSSFRow datarow = sheet.createRow(i+1);  
                HSSFCell cell0 = datarow.createCell(0);  
                HSSFRichTextString t0 = new HSSFRichTextString((String)map.get("rownum")+"");  
                cell0.setCellValue(t0);</string,></string,object>
Copy after login
rownum是数值型的,在循环中取值时,rownum变为null

Map<string,object> map=(Map<string, object="">) data.get(i);
            	HSSFRow datarow = sheet.createRow(i+1);  
                HSSFCell cell0 = datarow.createCell(0);  
                HSSFRichTextString t0 = new HSSFRichTextString(map.get("rownum")+"");  
                cell0.setCellValue(t0);
</string,></string,object>
Copy after login
去掉map前的(String),并清除一下缓存


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template