Enhanced to read and write formatted dates and formulas.#48
Open
HarshaM0211 wants to merge 21 commits intomillij:developfrom
Open
Enhanced to read and write formatted dates and formulas.#48HarshaM0211 wants to merge 21 commits intomillij:developfrom
HarshaM0211 wants to merge 21 commits intomillij:developfrom
Conversation
VyshnaviRG
reviewed
Oct 3, 2023
| boolean isFormatted() default false; | ||
| String format() default "dd/MM/yyyy"; | ||
|
|
||
| boolean isFromula() default false; |
VyshnaviRG
reviewed
Oct 3, 2023
| if (DateUtil.isCellDateFormatted(cell)) { | ||
|
|
||
| Map<String, String> formats = SpreadsheetWriter.getFormats(beanClz); | ||
| String cellFormat = formats.get(cellColName); |
VyshnaviRG
reviewed
Oct 3, 2023
| } else { | ||
| formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy"); | ||
| } | ||
|
|
There was a problem hiding this comment.
store default format as const..
Also, Can be written as
final String format = cellFormat != null ? cellFormat : defaultFormat; DateTimeFormatter formatter = DateTimeFormatter.ofPattern(format);
VyshnaviRG
reviewed
Oct 3, 2023
| @@ -0,0 +1,263 @@ | |||
| package io.github.millij.poi.ss.reader; | |||
VyshnaviRG
reviewed
Oct 3, 2023
| @Override | ||
| public <T> void read(Class<T> beanClz, InputStream is, int sheetNo, RowListener<T> listener) | ||
| throws SpreadsheetReadException { | ||
| // Sanity checks |
VyshnaviRG
reviewed
Oct 4, 2023
| import org.apache.poi.ss.usermodel.DateUtil; | ||
| import org.apache.poi.ss.usermodel.Row; | ||
| import org.apache.poi.ss.usermodel.Workbook; | ||
| // import org.apache.poi.util.SAXHelper; |
VyshnaviRG
reviewed
Oct 4, 2023
| // import io.github.millij.bean.Schedules; | ||
| import io.github.millij.poi.ss.writer.SpreadsheetWriter; | ||
|
|
||
| // import io.github.millij.bean.Schedules; |
VyshnaviRG
reviewed
Oct 4, 2023
| mapping.put(fieldName, ec.value()); | ||
|
|
||
| if (ec != null) { | ||
| String value = StringUtils.isNotEmpty(ec.value()) ? ec.value() : fieldName; |
VyshnaviRG
reviewed
Oct 4, 2023
| for (int i = 0, rowNum = 1; i < rowObjects.size(); i++, rowNum++) { | ||
| final XSSFRow row = sheet.createRow(rowNum); | ||
|
|
||
| final Map<String, String> dateFormatsMap = this.getFormats(beanType); |
VyshnaviRG
reviewed
Oct 4, 2023
| cellNo++; | ||
|
|
||
| } catch (Exception e) { | ||
| e.printStackTrace(); |
… prev. sheets--issue 24" This reverts commit 78995e4. reverting updates
Rupesh8844
reviewed
Oct 9, 2023
| Field[] fields = beanType.getDeclaredFields(); | ||
| final Field[] fields = beanType.getDeclaredFields(); | ||
| for (Field f : fields) { | ||
| String fieldName = f.getName(); |
Rupesh8844
reviewed
Oct 9, 2023
| @Test | ||
| public void writeDatesTest() throws IOException { | ||
|
|
||
| List<Schedule> schedules = new ArrayList<Schedule>(); |
This was referenced Oct 12, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modified entire XlsxReader.java file:
Replaced HSSF in XlsReader.java with XSSF everywhere and did the same logics.
Created two new methods "getFormats()" and "getFormulaCols" to store data about the columns that have to be date formatted and containing formulas.
Modified @SheetColumn
Added files and some modified data for Test cases.