All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dromara.hutool.poi.csv.CsvWriteConfig Maven / Gradle / Ivy

There is a newer version: 6.0.0.M3
Show newest version
/*
 * Copyright (c) 2023 looly([email protected])
 * Hutool is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *          https://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

package org.dromara.hutool.poi.csv;

import org.dromara.hutool.core.text.CharUtil;

import java.io.Serializable;

/**
 * CSV写出配置项
 *
 * @author looly
 */
public class CsvWriteConfig extends CsvConfig implements Serializable {
	private static final long serialVersionUID = 5396453565371560052L;

	/**
	 * 是否始终使用文本分隔符,文本包装符,默认false,按需添加
	 */
	protected boolean alwaysDelimitText;
	/**
	 * 换行符
	 */
	protected char[] lineDelimiter = {CharUtil.CR, CharUtil.LF};
	/**
	 * 是否使用安全模式,对可能存在DDE攻击的内容进行替换
	 */
	protected boolean ddeSafe;

	/**
	 * 文件末尾是否添加换行符
* 按照https://datatracker.ietf.org/doc/html/rfc4180#section-2 规范,末尾换行符可有可无。 */ protected boolean endingLineBreak; /** * 默认配置 * * @return 默认配置 */ public static CsvWriteConfig defaultConfig() { return new CsvWriteConfig(); } /** * 设置是否始终使用文本分隔符,文本包装符,默认false,按需添加 * * @param alwaysDelimitText 是否始终使用文本分隔符,文本包装符,默认false,按需添加 * @return this */ public CsvWriteConfig setAlwaysDelimitText(final boolean alwaysDelimitText) { this.alwaysDelimitText = alwaysDelimitText; return this; } /** * 设置换行符 * * @param lineDelimiter 换行符 * @return this */ public CsvWriteConfig setLineDelimiter(final char[] lineDelimiter) { this.lineDelimiter = lineDelimiter; return this; } /** * 设置是否动态数据交换安全,使用文本包装符包裹可能存在DDE攻击的内容
* 见:https://blog.csdn.net/weixin_41924764/article/details/108665746 * * @param ddeSafe dde安全 * @return this */ public CsvWriteConfig setDdeSafe(final boolean ddeSafe) { this.ddeSafe = ddeSafe; return this; } /** * 文件末尾是否添加换行符
* 按照https://datatracker.ietf.org/doc/html/rfc4180#section-2 规范,末尾换行符可有可无。 * * @param endingLineBreak 文件末尾是否添加换行符 * @return this */ public CsvWriteConfig setEndingLineBreak(final boolean endingLineBreak) { this.endingLineBreak = endingLineBreak; return this; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy