当前位置: 首页>>代码示例>>Java>>正文


Java JRCsvDataSource类代码示例

本文整理汇总了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));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:22,代码来源:XChartApp.java

示例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}");
}
 
开发者ID:vosskaem,项目名称:jasperstarter,代码行数:20,代码来源:DbNGTest.java

示例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();
    }
}
 
开发者ID:JockiHendry,项目名称:ireport-fork,代码行数:36,代码来源:JRCSVDataSourceConnection.java

示例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;  
}
 
开发者ID:ganzux,项目名称:SIRME,代码行数:9,代码来源:GenerateReport.java


注:本文中的net.sf.jasperreports.engine.data.JRCsvDataSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。