使用ureport导出报表报错:java.lang.IllegalArgumentException: Font size too small: 0.0

在使用Ureport进行报表导出时遇到`com.itextpdf.text.DocumentException: java.lang.IllegalArgumentException: Font size too small`错误。问题源于模板中cell-style缺少font-size属性,导致默认值为0。通过查看源码,发现CellStyle类中fontSize默认为0。解决方案是检查并确保模板中的cell-style包含font-size属性,或者在设计时设置。避免此类问题,需在生成模板时仔细核对样式设置。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

使用Ureport导出报表的时候报错:

com.itextpdf.text.DocumentException: java.lang.IllegalArgumentException: Font size too smal
	at com.itextpdf.text.pdf.PdfDocument.add(PdfDocument.java:821)
	at com.itextpdf.text.Document.add(Document.java:277)
	at com.bstek.ureport.export.pdf.PdfProducer.produce(PdfProducer.java:196)
	at com.bstek.ureport.export.ExportManagerImpl.exportPdf(ExportManagerImpl.java:102)

在网上搜了很多方法,基本没用,经过本人的细致分析,其实是模板的问题。

有问题的模板:
在这里插入图片描述 没问题的模板:
在这里插入图片描述大家可以看到font-size字段在有问题的模板中,cell-style这个节点是没有这个属性的。

但是为什么会是0呢?

于是翻了一下源码,我们可以看到,这里CellStyle中的fontSize是用基本数据类型int定义的,默认值会是0

package com.bstek.ureport.definition;

import java.awt.Font;
import java.io.Serializable;

import org.apache.commons.lang.StringUtils;
import org.codehaus.jackson.annotate.JsonIgnore;

import com.bstek.ureport.export.pdf.font.FontBuilder;


/**
 * @author Jacky.gao
 * @since 2017年1月18日
 */
public class CellStyle implements Serializable{
	private static final long serialVersionUID = 8327688051735343849L;
	private String bgcolor;
	private String forecolor;
	private int fontSize;
	private String fontFamily;
	private String format;
	private float lineHeight;
	private Alignment align;
	private Alignment valign;
	private Boolean bold;
	private Boolean italic;
	private Boolean underline;
	private Boolean wrapCompute;
	private Border leftBorder;
	private Border rightBorder;
	private Border topBorder;
	private Border bottomBorder;

问题解决:
在生成模板的时候,一定要自己核对一下cell-style中的font-size属性是否存在,不存在的话,要自己加一下,或者在设计面板中调整。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Jack_David

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值