ClosedXML / ClosedXML/ClosedXML.Report

Access original cell value from custom tag

Open
#364 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
647
Forks
122
PR merge metrics
No merged PRs in 30d

Description

I want to create a new custom tag that replaces all null values with #N/A. I can replace cell values from the tag but cannot distinguish empty strings from null because it outputs the same value to the cell. So, I need to inspect the original values accessible from the ProcessingContext Value property, but I cannot map the cell to the proper value.

```csharp
public class NullableTag : OptionTag
{
public override void Execute(ProcessingContext context)
{
var dataSource = context.Value as IDataSource;
var range = context.Range;

range.Cells().ToList().ForEach(cell =>
{
var row = range.FindRow(r => r.Contains(cell));
var values = dataSource.GetValue(row);

var value = ... // get value from values by cell address

if (value == null)
{
cell.FormulaA1 = "=NA()";
}

});
}

}
```
Could you point me in the right direction?

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by tracing the custom tag entry point through ProcessingContext.Value and IDataSource.GetValue(row), then inspect how range.Cells() and cell addresses relate to returned row values. Done means a custom tag can distinguish null from an empty string for each cell and replace only null values with =NA(); no file or test is named in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.