Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

easyexcel 2.2.10版本forceNewRow(Boolean.TRUE)覆盖原有数据 #3318

Open
superzhangquansong opened this issue Jul 8, 2023 · 1 comment · May be fixed by #3353
Open

easyexcel 2.2.10版本forceNewRow(Boolean.TRUE)覆盖原有数据 #3318

superzhangquansong opened this issue Jul 8, 2023 · 1 comment · May be fixed by #3353
Assignees
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@superzhangquansong
Copy link

public static void main(String[] args) throws Exception {
// 模板注意 用{} 来表示你要用的变量 如果本来就有"{","}" 特殊字符 用"{","}"代替
String templateFile = "/Users/super_song/Downloads/IntlContractTemplate.xlsx";
String targetFileName = "/Users/super_song/Downloads/testNew.xlsx";
// 创建一个工作簿对象
ExcelWriter workBook = EasyExcel.write(targetFileName).withTemplate(templateFile).build();
// 创建工作表对象
WriteSheet sheet = EasyExcel.writerSheet().build();
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
// 准备数据
List students = initFillData();
// 多组数据填充
workBook.fill(students, fillConfig, sheet);
// 关闭流 !!!
workBook.finish();
}
我的Excel主要分成三部分,头部是固定的内容,中间是动态插入数据的区域,底部是固定的内容。三部分都存在样式。
现在遇到的问题是我能成功插入数据,但是插入的数据会破坏底部的样式已经会覆盖底部的内容。

@superzhangquansong superzhangquansong added the help wanted Extra attention is needed label Jul 8, 2023
@frankggyy
Copy link
Collaborator

FillConfig需要设置direction = WriteDirectionEnum.VERTICALforceNewRow(Boolean.TRUE)才能生效。

FillConfig fillConfig = FillConfig.builder()
    .setDirection(WriteDirectionEnum.VERTICAL)
    .forceNewRow(Boolean.TRUE)
    .build()

// or
// FillConfig fillConfig = FillConfig.builder()
//    .forceNewRow(Boolean.TRUE)
//    .build()
//    .init()

@frankggyy frankggyy self-assigned this Jul 18, 2023
@frankggyy frankggyy added the question Further information is requested label Jul 18, 2023
@frankggyy frankggyy linked a pull request Jul 19, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants