How to parse from string to integer . i am using excel sheet with price values like ₹3,000, ₹4,000 … here i am using price=integer.parse(price) and price=int32.parse(price, cultureinfo.invariantculture) but its does not working . showing like this "cannot assign from type “system.double” to type “system.string” in assign activity
How did you get the price value from Excel?
I faced similar error in past when I’m doing data table select and I fixed inbelow way.Hope it helps.
dt.Select(“Convert([price], ‘System.String’) ='”+row(0).ToString.Trim)
@vvaidya . from read range output datatable to for each row in dt … getrow item there output = price in string
Hi,
I’m a little confused by this: price=integer.parse(price) and the error mentioning System.Double. What is the variable type of price and what are the source and type of the exception you get?
Regardless of this, here is some advice that may help you. A DataTable that is read from Excel will store its data in a format corresponding to the Excel column, like Integers for whole numbers, DateTimes for dates and Doubles for decimal numbers and currency values. Therefore your currency values, though displayed in Excel with a symbol, are most likely Doubles. You can access this typed data directly, for example to assign a particular Double row item to a Double variable: myDouble = row.Field(Of Double)(...)
.
You may also wish to convert it to a different type. In this case it is my experience that, while Get Row Item accepts any kind of variable as its output argument, it often has trouble converting the type of the table data to that of the output. You can do the conversion yourself, in which case it’s shortest and easiest to use a Convert function, like myInt32 = Convert.ToInt32(row(...))
. This is because a row item accessed this way is referenced as an Object, which is accepted by all Convert functions.