Skip to content

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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ExcelMapper/ExcelMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,10 @@

object GetCellValue(ICell cell, ColumnInfo targetColumn)
{
if (targetColumn.TextPlain)
{
return DataFormatter.FormatCellValue(cell);

Check warning on line 852 in ExcelMapper/ExcelMapper.cs

View check run for this annotation

Codecov / codecov/patch

ExcelMapper/ExcelMapper.cs#L851-L852

Added lines #L851 - L852 were not covered by tests
}
var formulaResult = cell.CellType == CellType.Formula && (targetColumn.PropertyType != typeof(string) || targetColumn.FormulaResult);
var cellType = formulaResult ? cell.CachedFormulaResultType : cell.CellType;

Expand Down
7 changes: 7 additions & 0 deletions ExcelMapper/TypeMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,13 @@
/// <c>true</c> if the property will be serialized as JSON; otherwise, <c>false</c>.
/// </value>
public bool Json { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to get the value in plain text.
/// </summary>
/// <value>
/// <c>true</c> if the property will be serialized as JSON; otherwise, <c>false</c>.
/// </value>
public bool TextPlain { get; set; }

Check warning on line 112 in ExcelMapper/TypeMapper.cs

View check run for this annotation

Codecov / codecov/patch

ExcelMapper/TypeMapper.cs#L112

Added line #L112 was not covered by tests

static readonly HashSet<Type> NumericTypes = new HashSet<Type>
{
Expand Down