Эх сурвалжийг харах

解决导出为纯数据excel过程中,数值过长时只显示小数点后一位的问题

sunyj 8 жил өмнө
parent
commit
6d8720e4f3

+ 2 - 5
src/main/java/com/uas/report/jasperreports/engine/export/CustomJRXlsExporter.java

@@ -93,12 +93,9 @@ public class CustomJRXlsExporter extends JRXlsExporter {
 			String textStr = styledText.getText();
 			TextValue textValue = getTextValue(textElement, textStr);
 			// 类型为String,但是实际值为数值,需设置为字符串类型,否则会提示转为数值型
-			if (textValue instanceof StringTextValue) {
-				if (isNumber(textStr)) {
-					baseStyle.setDataFormat(dataFormat.getFormat("@"));
-				}
+			if ((textValue instanceof StringTextValue && isNumber(textStr)) || textValue instanceof NumberTextValue) {
+				baseStyle.setDataFormat(dataFormat.getFormat("@"));
 			}
-
 			super.createTextCell(textElement, gridCell, colIndex, rowIndex, styledText, baseStyle, forecolor);
 
 			// 数值类型需明确指定,否则会提示转为数值型