Reputation: 497
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];
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
Upvotes: 2
Views: 253
Reputation: 126
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.
Upvotes: 1