ExcelMapper icon indicating copy to clipboard operation
ExcelMapper copied to clipboard

Creating a property to get the text plain of a cell ignoring given format in the excel sheet

Open davidaso28 opened this issue 5 years ago • 4 comments

Hello, First of all, I would like to say congratulations on your fantastic job with this library; it is handy and easy to understand.

I have made just a small change creating a property to determine if the library has to map the value ignoring the cell type or format established and just return plain text.

davidaso28 avatar Aug 20 '20 07:08 davidaso28

Codecov Report

Merging #72 into master will decrease coverage by 0.56%. The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
- Coverage   90.34%   89.77%   -0.57%     
==========================================
  Files           6        6              
  Lines         632      636       +4     
  Branches       77       78       +1     
==========================================
  Hits          571      571              
- Misses         50       53       +3     
- Partials       11       12       +1     
Impacted Files Coverage Δ
ExcelMapper/ExcelMapper.cs 86.94% <0.00%> (-0.65%) :arrow_down:
ExcelMapper/TypeMapper.cs 93.49% <0.00%> (-0.56%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5253506...d6610d8. Read the comment docs.

codecov[bot] avatar Aug 20 '20 07:08 codecov[bot]

What's the use case for this? Numeric cells that are mapped to string properties should automatically get the formatted value now.

mganss avatar Aug 20 '20 08:08 mganss

I have some cells that are formatted as date with content 10-11 when I call the fetch method I receive 10/11/2020 if I change the Data Formatter for a custom DataFormatter I would affect whole the date's interpretation. I want to determine with this flag when I want to get the text value and when I want to apply the data format.

Also, when you have a custom format in excel sheet you can avoid any data transformation by demand.

Please let me know if there is another way to achieve this.

Thanks for your quick reply.

davidaso28 avatar Aug 20 '20 08:08 davidaso28

Sorry, I don't get it. The cells that are date formatted as "10-11" should be mapped to a string property using the format specified in the Excel sheet so you'll get the string "10-11" in your string property. What exactly do you mean with the text value? Date cells are numeric cells and as such are stored as numbers in the Excel sheet. If you don't want/need the formatted string you can always map to a DateTime.

Can you post an example Excel sheet along with the class you're mapping to?

mganss avatar Aug 20 '20 09:08 mganss