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


Java CSVFormat.EXCEL属性代码示例

本文整理汇总了Java中org.apache.commons.csv.CSVFormat.EXCEL属性的典型用法代码示例。如果您正苦于以下问题:Java CSVFormat.EXCEL属性的具体用法?Java CSVFormat.EXCEL怎么用?Java CSVFormat.EXCEL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.apache.commons.csv.CSVFormat的用法示例。


在下文中一共展示了CSVFormat.EXCEL属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

public static void main(String[] args) throws IOException {
	java.io.Writer writer = new java.io.OutputStreamWriter(new java.io.FileOutputStream(new File("/tmp/test.csv")), Charset.forName("UTF-8"));
	CSVPrinter csvFilePrinter = new CSVPrinter(writer, CSVFormat.EXCEL);
	java.util.List<Object> header = new java.util.ArrayList<Object>();
	header.add("col1");
	header.add("col2");
	csvFilePrinter.printRecord(header);
	csvFilePrinter.printRecord(header);
	writer.close();
	csvFilePrinter.close();
}
 
开发者ID:c-ruttkies,项目名称:MetFragRelaunched,代码行数:11,代码来源:CandidateListWriterCSV.java

示例2: shouldUseFormatFromConstructor

@Test
public void shouldUseFormatFromConstructor() {
    CsvDataFormat dataFormat = new CsvDataFormat(CSVFormat.EXCEL);

    // Properly initialized
    assertSame(CSVFormat.EXCEL, dataFormat.getFormat());

    // Properly used
    assertEquals(CSVFormat.EXCEL, dataFormat.getActiveFormat());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:CsvDataFormatTest.java

示例3: doCreateRouteBuilder

@Override
protected RouteBuilder doCreateRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {

            // get Report SObject by DeveloperName
            from("direct:queryReport")
                .to("salesforce:query?sObjectClass=" + QueryRecordsReport.class.getName());
            
            from("direct:getRecentReports")
                .to("salesforce:getRecentReports");

            from("direct:getReportDescription")
                .to("salesforce:getReportDescription");
            
            from("direct:executeSyncReport")
                .to("salesforce:executeSyncReport");
            
            from("direct:executeAsyncReport")
                .to("salesforce:executeAsyncReport?includeDetails=true");
            
            from("direct:getReportInstances")
                .to("salesforce:getReportInstances");
            
            from("direct:getReportResults")
                .to("salesforce:getReportResults");

            CsvDataFormat csv = new CsvDataFormat(CSVFormat.EXCEL);

            // type converter test
            from("direct:convertResults")
                .convertBodyTo(List.class)
                .marshal(csv);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:37,代码来源:AnalyticsApiIntegrationTest.java

示例4: getCsvFormat

/**
 * Returns a CSVFormat object given the CSV format as a string.
 *
 * @param format
 * @return
 */
private CSVFormat getCsvFormat(String format) {
    CSVFormat csvFormat = null;

    switch (format.trim().toLowerCase()) {
        case "default":
            csvFormat = CSVFormat.DEFAULT;
            break;
        case "excel":
            csvFormat = CSVFormat.EXCEL;
            break;
        case "informixunload":
        case "informix-unload":
        case "informix_unload":
            csvFormat = CSVFormat.INFORMIX_UNLOAD;
            break;
        case "informixunloadcsv":
        case "informix-unload-csv":
        case "informix_unload_csv":
            csvFormat = CSVFormat.INFORMIX_UNLOAD_CSV;
            break;
        case "mysql":
            csvFormat = CSVFormat.MYSQL;
            break;
        case "postgres":
        case "postgresql-csv":
        case "postgresql_csv":
            csvFormat = CSVFormat.POSTGRESQL_CSV;
            break;
        case "postgresql-text":
        case "postgresql_text":
            csvFormat = CSVFormat.POSTGRESQL_TEXT;
            break;
        case "rfc4180":
            csvFormat = CSVFormat.RFC4180;
        case "tdf":
            csvFormat = CSVFormat.TDF;
        default:
            throw new RuntimeException(String.format("CSV format \"%s\" is not among the supported formats"));
    }

    return csvFormat;
}
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:48,代码来源:ReadCsv.java

示例5: CSVWriter

public CSVWriter() {
	this(CSVFormat.EXCEL);
}
 
开发者ID:redmyers,项目名称:484_P7_1-Java,代码行数:3,代码来源:CSVWriter.java

示例6: loadCSV

public static DataTable loadCSV(String fileName, String formatType, VariableType[] colTypesOverride, String[] colNamesOverride, boolean hasHeaderRow) {
	try {
		// use apache commons io + csv to load but convert to list of String[]
		// byte-order markers are handled if present at start of file.
		FileInputStream fis = new FileInputStream(fileName);
		final Reader reader = new InputStreamReader(new BOMInputStream(fis), "UTF-8");
		CSVFormat format;
		if ( formatType==null ) {
			format = hasHeaderRow ? CSVFormat.RFC4180.withHeader() : CSVFormat.RFC4180;
		}
		else {
			switch ( formatType.toLowerCase() ) {
				case "tsv":
					format = hasHeaderRow ? CSVFormat.TDF.withHeader() : CSVFormat.TDF;
					break;
				case "mysql":
					format = hasHeaderRow ? CSVFormat.MYSQL.withHeader() : CSVFormat.MYSQL;
					break;
				case "excel":
					format = hasHeaderRow ? CSVFormat.EXCEL.withHeader() : CSVFormat.EXCEL;
					break;
				case "rfc4180":
				default:
					format = hasHeaderRow ? CSVFormat.RFC4180.withHeader() : CSVFormat.RFC4180;
					break;
			}
		}
		final CSVParser parser = new CSVParser(reader, format);
		List<String[]> rows = new ArrayList<>();
		int numHeaderNames = parser.getHeaderMap().size();
		try {
			for (final CSVRecord record : parser) {
				String[] row = new String[record.size()];
				for (int j = 0; j<record.size(); j++) {
					row[j] = record.get(j);
				}
				rows.add(row);
			}
		}
		finally {
			parser.close();
			reader.close();
		}

		VariableType[] actualTypes = computeColTypes(rows, numHeaderNames);

		Set<String> colNameSet = parser.getHeaderMap().keySet();
		String[] colNames = colNameSet.toArray(new String[colNameSet.size()]);
		if ( colNamesOverride!=null ) {
			colNames = colNamesOverride;
		}
		if ( colTypesOverride!=null ) {
			actualTypes = colTypesOverride;
		}
		return fromStrings(rows, actualTypes, colNames, false);
	}
	catch (Exception e) {
		throw new IllegalArgumentException("Can't open and/or read "+fileName, e);
	}
}
 
开发者ID:parrt,项目名称:AniML,代码行数:60,代码来源:DataTable.java


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