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

03格式公式类型单元格无法获取DataFormatData #2444

Closed
ahjian opened this issue Apr 24, 2022 · 3 comments
Closed

03格式公式类型单元格无法获取DataFormatData #2444

ahjian opened this issue Apr 24, 2022 · 3 comments
Assignees
Labels
bug Something isn't working development completed Development completed, waiting for release

Comments

@ahjian
Copy link

ahjian commented Apr 24, 2022

03格式excel,单元格为公式,并设置单元格格式为数值,2位小数。

触发Bug的代码

   public class XLSBigDecimalConverter implements Converter<BigDecimal> {

	public Class<?> supportJavaTypeKey() {
        return BigDecimal.class;
    }

    public CellDataTypeEnum supportExcelTypeKey() {
        return CellDataTypeEnum.NUMBER;
    }

    public BigDecimal convertToJavaData(ReadCellData<?> cellData, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        BigDecimal val = cellData.getNumberValue();

        if (cellData.getDataFormatData() != null) {
            String format = cellData.getDataFormatData().getFormat();
            System.out.println(format);           
         }
        return val;
    }

    public WriteCellData<?> convertToExcelData(BigDecimal value, ExcelContentProperty contentProperty, GlobalConfiguration globalConfiguration) throws Exception {
        return null;
    }


}

cellData.getDataFormatData() 为空。代码错误应该在 FormulaRecordHandler 没有将DataFormat设置给tempCellData

@ahjian ahjian added the bug Something isn't working label Apr 24, 2022
@Melody0321
Copy link

hello, please give me some time to fix it, thanks. If you have more detailed information, you can contact me or comment here.

@shunui
Copy link

shunui commented May 6, 2022

@Melody0321 我也遇到了这个问题,表现是03版Excel, 单元格格式是 日期,公式是: Date(2022,5,6),排查下来,
是否可以修改类:FormulaRecordHandler, 在 ln: 63 增加如下代码:
tempCellData.setDataFormatData(dataFormatData);

@zhuangjiaju zhuangjiaju added the development completed Development completed, waiting for release label May 6, 2022
@zhuangjiaju
Copy link
Collaborator

该问题已经在3.1.0+版本里面解决,最新版本:Maven central

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working development completed Development completed, waiting for release
Projects
None yet
Development

No branches or pull requests

4 participants