本文整理汇总了Java中net.sf.jasperreports.engine.data.JRCsvDataSource类的典型用法代码示例。如果您正苦于以下问题:Java JRCsvDataSource类的具体用法?Java JRCsvDataSource怎么用?Java JRCsvDataSource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JRCsvDataSource类属于net.sf.jasperreports.engine.data包,在下文中一共展示了JRCsvDataSource类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fill
import net.sf.jasperreports.engine.data.JRCsvDataSource; //导入依赖的package包/类
/**
*
*/
public void fill() throws JRException
{
long start = System.currentTimeMillis();
Map<String, Object> parameters = new HashMap<String, Object>();
try
{
JRCsvDataSource xyds = new JRCsvDataSource(JRLoader.getLocationInputStream("data/xyDatasource.csv"), "UTF-8");
xyds.setRecordDelimiter("\r\n");
xyds.setUseFirstRowAsHeader(true);
parameters.put("xyDatasource", xyds);
}
catch (Exception e)
{
throw new JRException(e);
}
JasperFillManager.fillReportToFile("build/reports/XYChart.jasper", new HashMap<String, Object>(parameters), new JREmptyDataSource());
System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
示例2: testGetCsvDataSource
import net.sf.jasperreports.engine.data.JRCsvDataSource; //导入依赖的package包/类
/**
* Test of getCsvDataSource method, of class Db.
*/
@Test
public void testGetCsvDataSource() throws Exception {
System.out.println("getCsvDataSource");
Config config = new Config();
config.dbType = DsType.csv;
config.dataFile = new File("target/test-classes/csvExampleHeaders.csv");
config.csvCharset = "utf-8";
config.csvFieldDel = "|";
config.csvRecordDel = "\r\n";
config.csvFirstRow = true;
Db instance = new Db();
JRCsvDataSource jRCsvDataSource = instance.getCsvDataSource(config);
jRCsvDataSource.next();
Map names = jRCsvDataSource.getColumnNames();
assertEquals(names.toString(), "{Name=0, Street=1, City=2, Phone=3}");
}
示例3: getJRDataSource
import net.sf.jasperreports.engine.data.JRCsvDataSource; //导入依赖的package包/类
/**
* This method return an instanced JRDataDource to the database.
* If isJDBCConnection() return true => getJRDataSource() return false
*/
@Override
public net.sf.jasperreports.engine.JRDataSource getJRDataSource() {
try {
JRCsvDataSource ds = new JRCsvDataSource(new File(getFilename()));
if (this.getCustomDateFormat() != null && this.getCustomDateFormat().length() > 0)
{
ds.setDateFormat(new SimpleDateFormat(this.getCustomDateFormat()));
}
ds.setFieldDelimiter( getFieldDelimiter().charAt(0) );
ds.setRecordDelimiter( getRecordDelimiter());
ds.setUseFirstRowAsHeader( isUseFirstRowAsHeader());
if (!isUseFirstRowAsHeader())
{
String[] names = new String[getColumnNames().size()];
for (int i=0; i<names.length; ++i )
{
names[i] = ""+getColumnNames().elementAt(i);
}
ds.setColumnNames( names );
}
return ds;
} catch (Exception ex)
{
ex.printStackTrace();
return super.getJRDataSource();
}
}
示例4: getDataSource
import net.sf.jasperreports.engine.data.JRCsvDataSource; //导入依赖的package包/类
private static JRCsvDataSource getDataSource() throws JRException, IOException {
//JRLoader.getLocationInputStream(
JRCsvDataSource ds = new JRCsvDataSource(new File("C:\\wsfirext\\Firext_local\\WebContent\\WEB-INF\\reports\\test.csv"));
ds.setRecordDelimiter("\t");
ds.setUseFirstRowAsHeader(true);
ds.setFieldDelimiter(';');
return ds;
}