Skip to content

Different ways to get a cell value #2424

Open
@pvlst

Description

Do you want to request a feature or report a bug?

  • Bug
  • Feature
  • Question

Did you test against the latest CI build?

  • Yes
  • No

If you answered No, please test with the latest development build first.

Version of ClosedXML

0.102.3

What is the current behavior?

I'm struggling with writing clean and flawless code using the ClosedXML library. I usually have very simple scenarios, like these:

  1. I have a header cell or regular cell, that contains uncalculated constant string. And I want to get it as a string.
  2. I have a cell with a numeric, uncalculated constant value. And I want to get it as a string (for various reasons).
  3. I have a cell with some value, that may be or may not be calculated (i.e. contains a formula). I want to get the displayed value as a string.

In general, I can somehow get a value. But I don't know if this is the best approach. The documentation hasn't helped much.

What is the expected behavior or new feature?

The methods have clearly and thoroughly defined uses.

Is this a regression from the previous version?

Dunno.

Reproducibility

Code to reproduce problem:

string value;
value = worksheet.Row(row).Cell(1).GetValue<string>();
value = worksheet.Row(row).Cell(1).GetString();
value = worksheet.Row(row).Cell(1).GetText();
value = worksheet.Row(row).Cell(1).Value.ToString();
value = worksheet.Row(row).Cell(1).Value.GetText();
value = worksheet.Row(row).Cell(1).CachedValue.ToString();
value = worksheet.Row(row).Cell(1).CachedValue.GetText();

Can you please explain the differences thoroughly and possibly improve the documentation with such information? 🙏

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions