2

I have winform project in c# that I want to copy data from Excel cells to my datagirdview. But the excell cells is formatted with 2 digits after the comma.I want to get all value.

What i mean :

The excell cell value = 884,79258

Formatted value = 884,79

I am getting the data with Clipboard.GetText() method. Bu it gives me formatted value(884,79).

But i want the get all value which is 884,79258.

These are my codes

String[] lines = Clipboard.GetText().Split('\n');
string result = lines[0];

enter image description here

Thanx.

Edit:

Thanx to dr.nulll. The link that he shared is worked.

I am sharing the link below for those who have similar request.

Copying decimal values from Excel to C# causes to copy only displayed values

1
  • 1
    You need to do something like this. Commented Aug 20, 2022 at 16:50

1 Answer 1

1

Don’t go via the clipboard. Either use Excel via interop or a 3rd party library like NPOI. If you must use the clipboard then the value copied reflects the current formatting of the cell, so you need it set to show 4 digits after the decimal point.

Sign up to request clarification or add additional context in comments.

1 Comment

Hımm. But the user will copy data from excel sheet and will paste to my app. Actually i tried to copy data from excel and paste to word document. The result is same. THe reason of that the clipboard as you said.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.