String Double Quote

Hey guys!

In my Excel Application Scope I have an if condition which says: Convert.ToDouble(row.Item("cfb21
")) > 150
And exactly in that form because in my excel sheet the “cfb21” is written in that way with a new line. But UiPath doesn’t accept it and says “String constants must end with a double quote”. I can’t change the excel file so it has to be in that form. How can I solve this problem?

Stay healthy and best regards

Hi, @RandomGuy

First, try this way:

row.Item("cfb21" + Environment.NewLine)

If it does not work, try to:

  1. Read the cell where the column name is (in this case, the cell contaning “cfb21”)
  2. Use a Write Line to output the value of that cell
  3. Double-Click the output line and see what’s written in Message Details - “message”. You can also upload a screenshot here.

Capture213

@RandomGuy
have a look here:

Another Option could be to change/harmonize the columnname via the DataColumn Property ColumnName like:
Within Assign:
leftside dtVar.Column(ColumnInde).ColumnName
right side: “newNameString”

Is the column always in the same location? If so use the index number. You can do it as row(Columnindex). For example if cfb21 is index 10 then convert.todouble(row(10).tostring) may work.

Sadly the first approach doesn’t work.
I had to change the name of “cfb21” to FCFY21 but the case remains the same. Actually it says the same which I wrote above and I don’t understand it :smiley:
As you can see it says “FCFY21” and nothing else. The error says “If: Column ‘FCFY21’ does not belong to table DataTable.” Maybe there is a problem in the Excel file? image

I sent a reply with a screenshot and as you can I see it seems to be “FCFY21” and nothing else. Could there be a problem in the Excel file? The cell has the default format.

Yes. The name of the cell “FCFY21” is in the cell “AG6”.

Regarding the error, I would suggest:

After reading the input Excel, add this in a Write Line activity:
String.Join(", ", dt.Columns.Cast(Of Datacolumn).Select(function(x) x.ColumnName).ToArray())

Afterwards, check the name of your target column.

Okay the problem was that the column name was wrong because the “FCFY21” starts at row 6 and the first row was empty. Now I added the name “test” but again there is a problem. It says “If: Object cannot be cast from DBNull to other types.”
The column consists of several numbers in the “number” format. I am not allowed to change the column name actually or move the rows. I need to get started at the cell “AG7” where the numbers begin.

It’s good practice to perform a check like this, when converting to double:

If(Double.TryParse(yourVariable.ToString, 0), Double.Parse(yourVariable.ToString), 0 )

What this does:

  • if “yourVariable” can be converted to double, it will be converted.
  • otherwise, it will “convert” it to a default value of 0 (or other value that you define).

Ah okay I understand.
I now managed to do it with a colleague and actually it was very complex because in my excel file there are cells which are empty and others which are not. To solve this I needed a try catch exception and a lot of different things. Anyways, it works now as far as I can see :smiley:
Thank you everyone! :pray: