You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe I misunderstood something, but if I set mandatoryCell to true in the ExcelCellName annotation, it does not seem to throw an error when it comes across an empty cell. Instead, I just get null in the annotated field. Is this supposed to happen? If so, how could I get a CastingError to let the user know that a mandatory value is missing?
For reference, I'm using an XLSX file stream and POIJI 4.6.
Edit: After further digging through the source code, it seems like the mandatoryCell value is only checked in the HSSFUnmarshaler, which gets used for .xsl files or Sheets. I was able to trigger the PoijiMultiRowException by passing the Sheet directly, but I realized it does not really help the user in any way. I would ideally need just the row and column of the cell like with the CastingError, and not a total crash of the import process, but I guess for that you'd need to rewrite a large part of the codebase...
Edit 2: I found a hacky way around this: By setting the missing cell policy to CREATE_NULL_AS_BLANK in the worksheet before passing the Sheet, I can catch empty strings in my custom Casting and create custom errors there. This only works because all of my cells are mandatory though.
The text was updated successfully, but these errors were encountered:
Maybe I misunderstood something, but if I set
mandatoryCell
to true in theExcelCellName
annotation, it does not seem to throw an error when it comes across an empty cell. Instead, I just getnull
in the annotated field. Is this supposed to happen? If so, how could I get aCastingError
to let the user know that a mandatory value is missing?For reference, I'm using an XLSX file stream and POIJI 4.6.
Edit: After further digging through the source code, it seems like the
mandatoryCell
value is only checked in theHSSFUnmarshaler
, which gets used for.xsl
files orSheet
s. I was able to trigger thePoijiMultiRowException
by passing the Sheet directly, but I realized it does not really help the user in any way. I would ideally need just the row and column of the cell like with theCastingError
, and not a total crash of the import process, but I guess for that you'd need to rewrite a large part of the codebase...Edit 2: I found a hacky way around this: By setting the missing cell policy to
CREATE_NULL_AS_BLANK
in the worksheet before passing theSheet
, I can catch empty strings in my customCasting
and create custom errors there. This only works because all of my cells are mandatory though.The text was updated successfully, but these errors were encountered: