-
Notifications
You must be signed in to change notification settings - Fork 478
表头国际化 #653
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
base: main
Are you sure you want to change the base?
表头国际化 #653
Changes from 9 commits
6e57362
d285839
628f70b
ca5e74d
dee4d59
87a5779
cf030d3
c55b63f
6684619
2631579
dd04b9b
e28ca45
7101178
25b1ec1
17b1519
442a727
494dd77
09db594
fa9b6aa
2f143c7
d862ed0
41fe57a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.fesod.excel.demo.read; | ||
|
|
||
| import org.apache.fesod.excel.il8n.ExcelMessageSource; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Locale; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * AutoMessageSource | ||
| * | ||
| * @author GGBOUD | ||
| * @date 2025/10/20 | ||
| */ | ||
| public class AutoMessageSource implements ExcelMessageSource { | ||
| private final static Map<String, Map<Locale, String>> MESSAGE_MAP = new HashMap<>(); | ||
|
|
||
| @Override | ||
| public String resolveCode(String code, Locale locale) { | ||
| Map<Locale, String> localeMap = MESSAGE_MAP.get(code); | ||
| if (localeMap == null) { | ||
| return code; | ||
| } else { | ||
| String message = localeMap.get(locale); | ||
| return message == null ? code : message; | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void addMessage(String code, Locale locale, String msg) { | ||
| MESSAGE_MAP.computeIfAbsent(code, (key) -> new HashMap<>(4)).put(locale, msg); | ||
| } | ||
|
|
||
| public void addMessages(Map<String, String> messages, Locale locale) { | ||
| messages.forEach((code, msg) -> addMessage(code, locale, msg)); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.fesod.excel.demo.read; | ||
|
|
||
| import com.alibaba.fastjson2.JSON; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.apache.fesod.excel.context.AnalysisContext; | ||
| import org.apache.fesod.excel.read.listener.ReadListener; | ||
|
|
||
| /** | ||
| * Il8nHeadDemoDataListener | ||
| * | ||
| * @author GGBOUD | ||
| * @date 2025/10/20 | ||
| */ | ||
| @Slf4j | ||
| public class Il8nHeadDemoDataListener implements ReadListener<Il8nZhHeadDemoData> { | ||
|
|
||
| public Il8nHeadDemoDataListener() { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public void invoke(Il8nZhHeadDemoData data, AnalysisContext context) { | ||
| log.info("Parsed one row of data: {}", JSON.toJSONString(data)); | ||
| } | ||
|
|
||
| /** | ||
| * doAfterAllAnalysed | ||
| * | ||
| * @param context | ||
| */ | ||
| @Override | ||
| public void doAfterAllAnalysed(AnalysisContext context) { | ||
| log.info("All data has been parsed!"); | ||
| } | ||
|
|
||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.fesod.excel.demo.read; | ||
|
|
||
| import lombok.EqualsAndHashCode; | ||
| import lombok.Getter; | ||
| import lombok.Setter; | ||
| import org.apache.fesod.excel.annotation.ExcelProperty; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| /** | ||
| * 基础数据类.这里的排序和excel里面的排序一致 | ||
| * | ||
| * | ||
| **/ | ||
| @Getter | ||
| @Setter | ||
| @EqualsAndHashCode | ||
| public class Il8nZhHeadDemoData { | ||
| @ExcelProperty(value = {"head.str"}) | ||
| private String string; | ||
| @ExcelProperty(value = {"head.date"}) | ||
| private Date date; | ||
| @ExcelProperty(value = {"head.doubleData"}) | ||
| private Double doubleData; | ||
| @ExcelProperty(value = {"head.str1"}) | ||
| private String string1; | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,14 +19,6 @@ | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| package org.apache.fesod.excel.demo.write; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| import java.io.File; | ||||||||||||||||||||||||||
| import java.io.InputStream; | ||||||||||||||||||||||||||
| import java.net.URL; | ||||||||||||||||||||||||||
| import java.util.ArrayList; | ||||||||||||||||||||||||||
| import java.util.Date; | ||||||||||||||||||||||||||
| import java.util.HashSet; | ||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||
| import java.util.Set; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.ExcelWriter; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.FastExcel; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.annotation.ExcelProperty; | ||||||||||||||||||||||||||
|
|
@@ -35,13 +27,10 @@ | |||||||||||||||||||||||||
| import org.apache.fesod.excel.annotation.write.style.ColumnWidth; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.annotation.write.style.ContentRowHeight; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.annotation.write.style.HeadRowHeight; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.demo.read.Il8nZhHeadDemoData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.enums.CellDataTypeEnum; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.CommentData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.FormulaData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.HyperlinkData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.ImageData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.RichTextStringData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.WriteCellData; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.demo.read.AutoMessageSource; | ||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.*; | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| import org.apache.fesod.excel.metadata.data.*; | |
| import org.apache.fesod.excel.metadata.data.WriteCellData; | |
| import org.apache.fesod.excel.metadata.data.WriteRowData; | |
| import org.apache.fesod.excel.metadata.data.WriteSheetData; | |
| import org.apache.fesod.excel.metadata.data.WriteTableData; |
Copilot
AI
Oct 21, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace wildcard import with explicit imports to clearly document which POI classes are being used.
| import org.apache.poi.ss.usermodel.*; | |
| import org.apache.poi.ss.usermodel.Cell; | |
| import org.apache.poi.ss.usermodel.CellStyle; | |
| import org.apache.poi.ss.usermodel.CreationHelper; | |
| import org.apache.poi.ss.usermodel.DataFormat; | |
| import org.apache.poi.ss.usermodel.FillPatternType; | |
| import org.apache.poi.ss.usermodel.Font; | |
| import org.apache.poi.ss.usermodel.HorizontalAlignment; | |
| import org.apache.poi.ss.usermodel.IndexedColors; | |
| import org.apache.poi.ss.usermodel.Row; | |
| import org.apache.poi.ss.usermodel.Sheet; | |
| import org.apache.poi.ss.usermodel.Workbook; |
Uh oh!
There was an error while loading. Please reload this page.