我想導入net.sf.jasperreports.engine.export導出汽車的所有細節(數量,客戶端,構造函數,類型,顏色..)。所有的信息都存儲在數據庫中。實際上,我成功地生成了不同類型的文件(XML,doc,docx,pdf ..),名稱被正確命名,大小設置爲A4,並且文件可以位於正確的位置。但是所有的行都是空的,我想填充數據。我想使用fill()方法並使用JasperFillManager來填充空白。但它不起作用。我不知道如何使用JasperFillManager來查找所有信息。有人能幫助我嗎?JasperFillManager來填充導出的文件
/**
* Initializes this method.
*
* @param model
* @param pageType
* @param orientation
* @param outputType
* @param destination
*/
private void init(ExportModel model, PAGE_TYPE pageType,
PAGE_ORIENTATION orientation, OUTPUT_TYPE outputType,
String destination){
this.model = model;
this.printerData = new PrinterData();
this.printerData.setUseSql(false);
this.printerData.setPageFormat(pageType);
this.printerData.setPageOrientation(orientation);
this.printerData.setOutputType(outputType);
this.printerData.setDestination(destination);
}
這是類的初始。 我想編寫一個函數:
public static void fill()
{
try
{
JasperFillManager.fillReportToFile("static.jasper",null,new JREmptyDataSource());
} catch(JRException e)
{
e.printStackTrace();
}
}
}
非常感謝您!如果有一些示例代碼會更好!
「但它不起作用。」 - 什麼錯誤信息?什麼不行?你在期待什麼,而你取得了什麼? –
可以生成pdf和其他文檔,但裏面沒有數據。我想我填寫數據的方式是錯誤的。您能否告訴我如何在生成的文檔中填充數據? – user1643305