mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-04-19 03:01:48 +08:00
fix name
This commit is contained in:
parent
7a420029db
commit
ddae419a10
@ -15,7 +15,7 @@ package org.dromara.hutool.core.io.file;
|
||||
import org.dromara.hutool.core.io.IORuntimeException;
|
||||
import org.dromara.hutool.core.io.file.visitor.CopyVisitor;
|
||||
import org.dromara.hutool.core.lang.Assert;
|
||||
import org.dromara.hutool.core.lang.copier.SrcToDestCopier;
|
||||
import org.dromara.hutool.core.lang.copier.SrcToTargetCopier;
|
||||
import org.dromara.hutool.core.util.ObjUtil;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -27,7 +27,7 @@ import java.nio.file.*;
|
||||
* @author looly
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public class PathCopier extends SrcToDestCopier<Path, PathCopier> {
|
||||
public class PathCopier extends SrcToTargetCopier<Path, PathCopier> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
@ -265,7 +265,7 @@ public class PathUtil {
|
||||
* @since 5.8.27
|
||||
*/
|
||||
public static Path copy(final InputStream src, final Path target, final CopyOption... options) throws IORuntimeException {
|
||||
Assert.notNull(target, "Destination File or directory is null !");
|
||||
Assert.notNull(target, "Target File or directory is null !");
|
||||
|
||||
// 创建级联父目录
|
||||
mkParentDirs(target);
|
||||
|
@ -25,7 +25,7 @@ import java.util.function.Predicate;
|
||||
* @param <C> 本类的类型。用于set方法返回本对象,方便流式编程
|
||||
* @since 3.0.9
|
||||
*/
|
||||
public abstract class SrcToDestCopier<T, C extends SrcToDestCopier<T, C>> implements Copier<T>, Serializable{
|
||||
public abstract class SrcToTargetCopier<T, C extends SrcToTargetCopier<T, C>> implements Copier<T>, Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 源 */
|
@ -54,7 +54,7 @@ public class ExcelBase<T extends ExcelBase<T, C>, C extends ExcelConfig> impleme
|
||||
/**
|
||||
* 目标文件,如果用户读取为流或自行创建的Workbook或Sheet,此参数为{@code null}
|
||||
*/
|
||||
protected File destFile;
|
||||
protected File targetFile;
|
||||
/**
|
||||
* 工作簿
|
||||
*/
|
||||
|
@ -71,7 +71,7 @@ public class ExcelReader extends ExcelBase<ExcelReader, ExcelReadConfig> {
|
||||
*/
|
||||
public ExcelReader(final File bookFile, final int sheetIndex) {
|
||||
this(WorkbookUtil.createBook(bookFile, true), sheetIndex);
|
||||
this.destFile = bookFile;
|
||||
this.targetFile = bookFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +82,7 @@ public class ExcelReader extends ExcelBase<ExcelReader, ExcelReadConfig> {
|
||||
*/
|
||||
public ExcelReader(final File bookFile, final String sheetName) {
|
||||
this(WorkbookUtil.createBook(bookFile, true), sheetName);
|
||||
this.destFile = bookFile;
|
||||
this.targetFile = bookFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -372,11 +372,11 @@ public class ExcelReader extends ExcelBase<ExcelReader, ExcelReadConfig> {
|
||||
* @since 4.0.6
|
||||
*/
|
||||
public ExcelWriter getWriter() {
|
||||
if (null == this.destFile) {
|
||||
if (null == this.targetFile) {
|
||||
// 非读取文件形式,直接获取sheet操作。
|
||||
return new ExcelWriter(this.sheet);
|
||||
}
|
||||
return ExcelUtil.getWriter(this.destFile, this.sheet.getSheetName());
|
||||
return ExcelUtil.getWriter(this.targetFile, this.sheet.getSheetName());
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------- Private methods start
|
||||
|
@ -130,7 +130,7 @@ public class BigExcelWriter extends ExcelWriter {
|
||||
*/
|
||||
public BigExcelWriter(final File destFile, final String sheetName) {
|
||||
this(destFile.exists() ? WorkbookUtil.createSXSSFBook(destFile) : WorkbookUtil.createSXSSFBook(), sheetName);
|
||||
this.destFile = destFile;
|
||||
this.targetFile = destFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -189,7 +189,7 @@ public class BigExcelWriter extends ExcelWriter {
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public void close() {
|
||||
if (null != this.destFile && !isFlushed) {
|
||||
if (null != this.targetFile && !isFlushed) {
|
||||
flush();
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
|
||||
*/
|
||||
public ExcelWriter(final File destFile, final String sheetName) {
|
||||
this(WorkbookUtil.createBookForWriter(destFile), sheetName);
|
||||
this.destFile = destFile;
|
||||
this.targetFile = destFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -385,7 +385,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
|
||||
* @return this
|
||||
*/
|
||||
public ExcelWriter setDestFile(final File destFile) {
|
||||
this.destFile = destFile;
|
||||
this.targetFile = destFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -1303,7 +1303,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public ExcelWriter flush() throws IORuntimeException {
|
||||
return flush(this.destFile);
|
||||
return flush(this.targetFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1362,7 +1362,7 @@ public class ExcelWriter extends ExcelBase<ExcelWriter, ExcelWriteConfig> {
|
||||
*/
|
||||
@Override
|
||||
public void close() {
|
||||
if (null != this.destFile) {
|
||||
if (null != this.targetFile) {
|
||||
flush();
|
||||
}
|
||||
closeWithoutFlush();
|
||||
|
@ -41,7 +41,7 @@ public class Word07Writer implements Closeable {
|
||||
/**
|
||||
* 目标文件
|
||||
*/
|
||||
protected File destFile;
|
||||
protected File targetFile;
|
||||
/**
|
||||
* 是否被关闭
|
||||
*/
|
||||
@ -59,10 +59,10 @@ public class Word07Writer implements Closeable {
|
||||
/**
|
||||
* 构造
|
||||
*
|
||||
* @param destFile 写出的文件
|
||||
* @param targetFile 写出的文件
|
||||
*/
|
||||
public Word07Writer(final File destFile) {
|
||||
this(DocUtil.create(destFile), destFile);
|
||||
public Word07Writer(final File targetFile) {
|
||||
this(DocUtil.create(targetFile), targetFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -78,11 +78,11 @@ public class Word07Writer implements Closeable {
|
||||
* 构造
|
||||
*
|
||||
* @param doc {@link XWPFDocument}
|
||||
* @param destFile 写出的文件
|
||||
* @param targetFile 写出的文件
|
||||
*/
|
||||
public Word07Writer(final XWPFDocument doc, final File destFile) {
|
||||
public Word07Writer(final XWPFDocument doc, final File targetFile) {
|
||||
this.doc = doc;
|
||||
this.destFile = destFile;
|
||||
this.targetFile = targetFile;
|
||||
}
|
||||
|
||||
// endregion
|
||||
@ -99,11 +99,11 @@ public class Word07Writer implements Closeable {
|
||||
/**
|
||||
* 设置写出的目标文件
|
||||
*
|
||||
* @param destFile 目标文件
|
||||
* @param targetFile 目标文件
|
||||
* @return this
|
||||
*/
|
||||
public Word07Writer setDestFile(final File destFile) {
|
||||
this.destFile = destFile;
|
||||
public Word07Writer setTargetFile(final File targetFile) {
|
||||
this.targetFile = targetFile;
|
||||
return this;
|
||||
}
|
||||
|
||||
@ -249,13 +249,13 @@ public class Word07Writer implements Closeable {
|
||||
/**
|
||||
* 将Excel Workbook刷出到预定义的文件<br>
|
||||
* 如果用户未自定义输出的文件,将抛出{@link NullPointerException}<br>
|
||||
* 预定义文件可以通过{@link #setDestFile(File)} 方法预定义,或者通过构造定义
|
||||
* 预定义文件可以通过{@link #setTargetFile(File)} 方法预定义,或者通过构造定义
|
||||
*
|
||||
* @return this
|
||||
* @throws IORuntimeException IO异常
|
||||
*/
|
||||
public Word07Writer flush() throws IORuntimeException {
|
||||
return flush(this.destFile);
|
||||
return flush(this.targetFile);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -312,7 +312,7 @@ public class Word07Writer implements Closeable {
|
||||
@SuppressWarnings("resource")
|
||||
@Override
|
||||
public void close() {
|
||||
if (null != this.destFile) {
|
||||
if (null != this.targetFile) {
|
||||
flush();
|
||||
}
|
||||
closeWithoutFlush();
|
||||
|
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright (c) 2024. looly(loolly@aliyun.com)
|
||||
* 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.excel.writer;
|
||||
|
||||
import org.dromara.hutool.core.collection.ListUtil;
|
||||
import org.dromara.hutool.core.io.file.FileUtil;
|
||||
import org.dromara.hutool.poi.excel.ExcelUtil;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WriteImgTest {
|
||||
@Test
|
||||
@Disabled
|
||||
void writeTest() {
|
||||
final File file = FileUtil.file("d:/test/hutool.png");
|
||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/images.xlsx");
|
||||
for (int i = 0; i < 6; i++) {
|
||||
writer.writeRow(ListUtil.of(file, file, file, file, file, file));
|
||||
}
|
||||
writer.close();
|
||||
}
|
||||
}
|
@ -3,12 +3,14 @@ package org.dromara.hutool.poi.excel.writer;
|
||||
import org.dromara.hutool.poi.excel.ExcelUtil;
|
||||
import org.dromara.hutool.poi.excel.SimpleClientAnchor;
|
||||
import org.dromara.hutool.poi.excel.style.LineStyle;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class WriteLineShapeTest {
|
||||
@Test
|
||||
@Disabled
|
||||
void testWriteLineShape() {
|
||||
// Setup
|
||||
final ExcelWriter writer = ExcelUtil.getWriter("d:/test/lineShape.xlsx");
|
||||
|
Loading…
x
Reference in New Issue
Block a user